From: joey Date: Wed, 29 Mar 2006 07:24:03 +0000 (+0000) Subject: css support X-Git-Tag: 1.0~116 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5591d621b90855beeb5460f0ac11279d19835699;p=ikiwiki.git css support --- diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 52da67b9a..67bce6795 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -38,6 +38,7 @@ sub cgi_recentchanges ($) { #{{{ indexlink => indexlink(), wikiname => $config{wikiname}, changelog => [rcs_recentchanges(100)], + styleurl => styleurl(), ); print $q->header, $template->output; } #}}} @@ -64,7 +65,8 @@ sub cgi_signin ($$) { #{{{ action => $q->request_uri, header => 0, template => (-e "$config{templatedir}/signin.tmpl" ? - "$config{templatedir}/signin.tmpl" : "") + "$config{templatedir}/signin.tmpl" : ""), + stylesheet => styleurl(), ); $form->field(name => "name", required => 0); @@ -228,7 +230,8 @@ sub cgi_prefs ($$) { #{{{ params => $q, action => $q->request_uri, template => (-e "$config{templatedir}/prefs.tmpl" ? - "$config{templatedir}/prefs.tmpl" : "") + "$config{templatedir}/prefs.tmpl" : ""), + stylesheet => styleurl(), ); my @buttons=("Save Preferences", "Logout", "Cancel"); @@ -323,6 +326,7 @@ sub cgi_editpage ($$) { #{{{ $form->tmpl_param("indexlink", indexlink()); $form->tmpl_param("helponformattinglink", htmllink("", "HelpOnFormatting", 1)); + $form->tmpl_param("styleurl", styleurl()); if (! $form->submitted) { $form->field(name => "rcsinfo", value => rcs_prepedit($file), force => 1); diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 1fc047a62..7d1e8ee53 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -227,6 +227,7 @@ sub genpage ($$$) { #{{{ backlinks => [backlinks($page)], discussionlink => htmllink($page, "Discussion", 1, 1), mtime => scalar(gmtime($mtime)), + styleurl => styleurl($page), ); return $template->output; diff --git a/basewiki/style.css b/basewiki/style.css new file mode 100644 index 000000000..82a01d8a0 --- /dev/null +++ b/basewiki/style.css @@ -0,0 +1,68 @@ +#header h1 { + margin: 0; + padding: 2px 0; +} + +#actions ul { + margin: 0; + padding: 2px; + list-style-type: none; + border-bottom: 1px solid #000; +} + +#actions li { + display: inline; + padding: .2em .4em; +} + +#content { + border-bottom: 1px solid #000; +} + +/* Used for adding a blog page. */ +#blogform { + padding: 10px 10px; + border: 1px solid #aaa; + background: #eee; +} + +#backlinks { + margin: 1em 0; +} + +#footer { + margin: 1em 0; +} + +#pageinfo { + font-style: italic; +} + +/* Used for invalid form fields. */ +.fb_invalid { + color: red; +} + +/* Used for required form fields. */ +.fb_required { + fornt-style: bold; +} + +/* RSS button. */ +.rssbutton { + background: #ff6600; + color: white !important; + border-left: 1px solid #cc9966; + border-top: 1px solid #ccaa99; + border-right: 1px solid #993300; + border-bottom: 1px solid #331100; + padding: 0px 0.5em 0px 0.5em; + font-family: helvetica, arial, sans-serif; + font-weight: bold; + font-size: small; + text-decoration: none; + margin-top: 1em; +} +.rssbutton:hover { + background: #ff9900; +} diff --git a/doc/todo/html.mdwn b/doc/todo/html.mdwn index c6feb1b66..741b42ccd 100644 --- a/doc/todo/html.mdwn +++ b/doc/todo/html.mdwn @@ -1,8 +1,8 @@ -Add css and prettify. Make RecentChanges use table for +Create some nice stylesheets. Make RecentChanges use table for formatting, and images to indicate web vs svn commits and to link to diffs. All of this should be doable w/o touching a single line of code, just -editing the [[templates]] BTW. +editing the [[templates]] and/or editing [[style.css]] BTW. ## html validation @@ -41,6 +41,5 @@ editing the [[templates]] BTW. markdown enclosing it in other spanning tags in some cases. I've implemented this hack now. :-/ --[[Joey]] - * This page is now valid, although the validator conplains at having to guess the encoding. Should the encoding be forced to utf-8 in the templates? - +This page is now valid. Test: [validate this page](http://validator.w3.org/check?url=referer) diff --git a/ikiwiki b/ikiwiki index d1173d399..7a16be3ca 100755 --- a/ikiwiki +++ b/ikiwiki @@ -265,6 +265,16 @@ sub cgiurl (@) { #{{{ return $config{cgiurl}."?".join("&", map "$_=$params{$_}", keys %params); } #}}} +sub styleurl (;$) { #{{{ + my $page=shift; + + return "$config{url}/style.css" if ! defined $page; + + $page=~s/[^\/]+$//; + $page=~s/[^\/]+\//..\//g; + return $page."style.css"; +} #}}} + sub htmllink ($$;$$$) { #{{{ my $page=shift; my $link=shift; @@ -300,7 +310,7 @@ sub htmllink ($$;$$$) { #{{{ $bestlink=File::Spec->abs2rel($bestlink, dirname($page)); if (! $noimageinline && isinlinableimage($bestlink)) { - return "\"$linktext\""; + return "\"$linktext\""; } return "$linktext"; } #}}} @@ -395,6 +405,7 @@ sub misctemplate ($$) { #{{{ indexlink => indexlink(), wikiname => $config{wikiname}, pagebody => $pagebody, + styleurl => styleurl(), ); return $template->output; }#}}} diff --git a/templates/blogpost.tmpl b/templates/blogpost.tmpl index 8e4bb6a7d..22253d60b 100644 --- a/templates/blogpost.tmpl +++ b/templates/blogpost.tmpl @@ -1,9 +1,9 @@ -
-
- - - -Add a new post titled: - + +
+ + + +Add a new post titled: + +
-
diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl index f77f45036..1733483d3 100644 --- a/templates/editpage.tmpl +++ b/templates/editpage.tmpl @@ -1,7 +1,11 @@ -<TMPL_VAR FORM-TITLE> + + +<TMPL_VAR FORM-TITLE> + +

@@ -31,8 +35,12 @@ Optional comment about this change:


+ +
+
diff --git a/templates/inlinepagetitle.tmpl b/templates/inlinepagetitle.tmpl index 06af446ef..91f34b1d3 100644 --- a/templates/inlinepagetitle.tmpl +++ b/templates/inlinepagetitle.tmpl @@ -1,4 +1,4 @@

-
+
(posted )

diff --git a/templates/misc.tmpl b/templates/misc.tmpl index 3e78c3162..98d60d703 100644 --- a/templates/misc.tmpl +++ b/templates/misc.tmpl @@ -1,7 +1,11 @@ -<TMPL_VAR TITLE> + + +<TMPL_VAR TITLE> + +

diff --git a/templates/page.tmpl b/templates/page.tmpl index e22169323..8b018ddfb 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -1,57 +1,66 @@ -<TMPL_VAR TITLE> + + +<TMPL_VAR TITLE> + + + -

+

-
+
-
+
+ -

- +

diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl index 4ab53b892..9836e1f2a 100644 --- a/templates/recentchanges.tmpl +++ b/templates/recentchanges.tmpl @@ -1,15 +1,20 @@ -<TMPL_VAR TITLE> + + +<TMPL_VAR TITLE> + + + -
- +
  • @@ -32,6 +37,7 @@
+