html validation fixes:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 29 Mar 2006 03:18:21 +0000 (03:18 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 29 Mar 2006 03:18:21 +0000 (03:18 +0000)
 - escape & in urls (also clean up cgi url generation)
 - since markdown wraps inlined pages in <p></p>, close and re-open
   the paragraph tags when generating the embedded html
 - added XHTML 1.0 doctypes to templates
 - fixed <hr /> and <br /> in templates
 - add an alt attribute to inline images, based on the WikiLink to the
   image. Allows things like [[my_image|img.png]] to customise alt text.

IkiWiki/CGI.pm
IkiWiki/Render.pm
doc/todo/html.mdwn
ikiwiki
templates/blogpost.tmpl
templates/editpage.tmpl
templates/misc.tmpl
templates/page.tmpl
templates/recentchanges.tmpl

index 7c12bee5bdef4b091ab360d465a908acf01d39be..52da67b9a13453ba4c83fc81edc474a4da89d360 100644 (file)
@@ -144,12 +144,13 @@ sub cgi_signin ($$) { #{{{
                        $session->param("name", $form->field("name"));
                        if (defined $form->field("do") && 
                            $form->field("do") ne 'signin') {
-                               print $q->redirect(
-                                       "$config{cgiurl}?do=".$form->field("do").
-                                       "&page=".$form->field("page").
-                                       "&title=".$form->field("title").
-                                       "&subpage=".$form->field("subpage").
-                                       "&from=".$form->field("from"));;
+                               print $q->redirect(cgiurl(
+                                       do => $form->field("do"),
+                                       page => $form->field("page"),
+                                       title => $form->field("title"),
+                                       subpage => $form->field("subpage"),
+                                       from => $form->field("from"),
+                               ));
                        }
                        else {
                                print $q->redirect($config{url});
index f897b9b1397f2dd5d810c5d589b87997de30960e..1fc047a62f78ed8b21d2cde47940363a65930d09 100644 (file)
@@ -186,7 +186,7 @@ sub postprocess_html_inline { #{{{
                $ret.=$template->output;
        }
        
-       return $ret;
+       return "</p>$ret<p>";
 } #}}}
 
 sub genpage ($$$) { #{{{
@@ -202,10 +202,10 @@ sub genpage ($$$) { #{{{
                filename => "$config{templatedir}/page.tmpl");
        
        if (length $config{cgiurl}) {
-               $template->param(editurl => "$config{cgiurl}?do=edit&page=$page");
-               $template->param(prefsurl => "$config{cgiurl}?do=prefs");
+               $template->param(editurl => cgiurl(do => "edit", page => $page));
+               $template->param(prefsurl => cgiurl(do => "prefs"));
                if ($config{rcs}) {
-                       $template->param(recentchangesurl => "$config{cgiurl}?do=recentchanges");
+                       $template->param(recentchangesurl => cgiurl(do => "recentchanges"));
                }
        }
 
index ba167ea6231ae80557d3fee6bb92465ea28e6b58..cb77774b5d83fdbf4748e1871718fbd790b3cf6a 100644 (file)
@@ -6,8 +6,35 @@ editing the [[templates]] BTW.
 
 Current problems:
 
-  * A doctype should be added: do we want XHTML 1.0 or HTML 4.01 Trans as default?
-  * If XHTML: In templates &lt;hr&gt; should become &lt;hr\&gt; etc.
+  * A doctype should be added: do we want XHTML 1.0 or HTML 4.01 Trans as
+    default?
+    
+       Need to choose a doctype that corresponds to what [[MarkDown]]
+       generates. For example, it does generate &lt;hr /&gt;
+       So xhml seems a good fit and I'm going to add that to the
+       templates. 
+       
+       One consideration of course is that regular users might embed html
+       that uses deprecated presentational elements like &lt;center&gt;.
+       --[[Joey]]
+       
+  * If XHTML: In templates &lt;hr&gt; should become &lt;hr /&gt; etc.
   * Image wikilinks should provide an alt text (maybe '$filname wiki-image'?).
+
+       Now it will be the text of the [[WikiLink]], which even allows
+       setting a custom alt text like this: \[[my_alt_text|image.png]]
+       --[[Joey]]
+       
   * &'s in (cgi-)url's must be escaped as &amp;amp;.
+  
+       Fixed --[[Joey]]
+       
   * [ [inlinepage] ] gets wrapped in &lt;p&gt;...&lt;/p&gt; which has a high chance of invalidating the page.
+
+       Since markdown does this, the only way I can think to fix it is to
+       make the inlined page text start with &lt;/p&gt; and end with
+       &lt;p&gt;. Ugly, and of course there could be problems with
+       markdown enclosing it in other spanning tags in some cases.
+       I've implemented this hack now. :-/ --[[Joey]]
+
+Test: [validate this page](http://validator.w3.org/check?url=referer)
diff --git a/ikiwiki b/ikiwiki
index 44a7abaf46a438456be7c22c7e02345a2af1c65b..62a9767b9346bbad0cc4bd8a8c1ab4c3db6f6cb9 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -259,6 +259,12 @@ sub titlepage ($) { #{{{
        return $title;
 } #}}}
 
+sub cgiurl (@) { #{{{
+       my %params=@_;
+
+       return $config{cgiurl}."?".join("&amp;", map "$_=$params{$_}", keys %params);
+} #}}}
+
 sub htmllink ($$;$$$) { #{{{
        my $page=shift;
        my $link=shift;
@@ -286,13 +292,15 @@ sub htmllink ($$;$$$) { #{{{
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
-               return "<span><a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$linktext</span>"
+               return "<span><a href=\"".
+                       cgiurl(do => "create", page => $link, from =>$page).
+                       "\">?</a>$linktext</span>"
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
        
        if (! $noimageinline && isinlinableimage($bestlink)) {
-               return "<img src=\"$bestlink\">";
+               return "<img src=\"$bestlink\" alt=\"$linktext\">";
        }
        return "<a href=\"$bestlink\">$linktext</a>";
 } #}}}
index 5ded359a18448570f3371f2f4227ac3d96f7e5b7..8e4bb6a7dcba9b29ee944100739c131a9418e293 100644 (file)
@@ -1,4 +1,4 @@
-<hr>
+<hr />
 <form action="<TMPL_VAR CGIURL>" method="GET">
 <input type="hidden" name="do" value="blog">
 <input type="hidden" name="from" value="<TMPL_VAR ROOTPAGE>">
@@ -6,4 +6,4 @@
 Add a new post titled: <input name=title size=40>
 <input type="submit" value="Edit">
 </form>
-<hr>
+<hr />
index c1e7113b4b45c2e5d9ad4374b363b87058a9443b..f77f450364c30af85589d522d3a8243557fefe77 100644 (file)
@@ -1,3 +1,5 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head><title><TMPL_VAR FORM-TITLE></title></head>
 <body>
@@ -16,18 +18,18 @@ confict and commit again to save your changes.
 <TMPL_VAR FIELD-FROM>
 <TMPL_VAR FIELD-RCSINFO>
 <TMPL_IF NAME="PAGE_SELECT">
-Page location: <TMPL_VAR FIELD-PAGE><br>
+Page location: <TMPL_VAR FIELD-PAGE><br />
 <TMPL_ELSE>
 <TMPL_VAR FIELD-PAGE>
 </TMPL_IF>
-<TMPL_VAR FIELD-CONTENT><br>
+<TMPL_VAR FIELD-CONTENT><br />
 <TMPL_IF NAME="CAN_COMMIT">
-Optional comment about this change:</br>
-<TMPL_VAR FIELD-COMMENTS><br>
+Optional comment about this change:<br />
+<TMPL_VAR FIELD-COMMENTS><br />
 </TMPL_IF>
 <TMPL_VAR FORM-SUBMIT>
 <TMPL_VAR FORM-END>
-<hr>
+<hr />
 <TMPL_IF NAME="PAGE_PREVIEW">
 <h1>Page preview:</h1>
 <TMPL_VAR PAGE_PREVIEW>
index a8ee1684b9ec6ab484d0d107f07915a4747ed7fd..3e78c31622d3266d87b60691fb7d9418ceaec4c7 100644 (file)
@@ -1,3 +1,5 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head><title><TMPL_VAR TITLE></title></head>
 <body>
index 468361a9d05657890b5c261f96b6767056562d85..9cef35dc69ab7042add35d4a6e46741c60c26ebd 100644 (file)
@@ -1,3 +1,5 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head><title><TMPL_VAR TITLE></title></head>
 <body>
 <a href="<TMPL_VAR PREFSURL>">Preferences</a>&nbsp;
 </TMPL_IF>
 
-<TMPL_VAR DISCUSSIONLINK><br>
+<TMPL_VAR DISCUSSIONLINK><br />
 
-<hr>
+<hr />
 <TMPL_VAR CONTENT>
-<hr>
+<hr />
 
 <TMPL_IF NAME="BACKLINKS">
 <p>Links:
index b42975e95c69fc493d1fcde0c8e2fd8c0213a271..4ab53b89222463b5bad7ff71d8fc2b5a041ce23f 100644 (file)
@@ -1,3 +1,5 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head><title><TMPL_VAR TITLE></title></head>
 <body>
@@ -6,7 +8,7 @@
 <TMPL_VAR INDEXLINK>/ <TMPL_VAR TITLE>
 </h1>
 
-<hr>
+<hr />
 
 <ul>
 <TMPL_LOOP NAME="CHANGELOG">
                                (<a href="<TMPL_VAR NAME="DIFFURL">">diff</a>)
                        </TMPL_IF>
                </TMPL_LOOP>
-               <br>
+               <br />
                <!-- <TMPL_VAR NAME="COMMITTYPE"> -->
                changed <TMPL_VAR NAME="WHEN"> by <TMPL_VAR NAME="USER">:
                <i>
                <TMPL_LOOP NAME="MESSAGE">
                        <TMPL_IF NAME="LINE">
-                               <TMPL_VAR NAME="LINE"><br>
+                               <TMPL_VAR NAME="LINE"><br />
                        </TMPL_IF>
                </TMPL_LOOP>
                </i>