changeset 469:ff99c7d6ffcb

Added rst admonition class patch by TiagoMacambira imported from: moin--main--1.5--patch-473
author Alexander Schremmer <alex@alexanderweb.de.tla>
date Sun, 12 Mar 2006 23:47:29 +0000
parents dc71d3e23d44
children 957d482215ac
files ChangeLog MoinMoin/parser/rst.py contrib/stylesheets/readme.txt contrib/stylesheets/speed.css docs/CHANGES
diffstat 5 files changed, 124 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 08 21:30:00 2006 +0000
+++ b/ChangeLog	Sun Mar 12 23:47:29 2006 +0000
@@ -2,6 +2,27 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-13 00:47:29 GMT	Alexander Schremmer <alex@alexanderweb.de.tla>	patch-473
+
+    Summary:
+      Added rst admonition class patch by TiagoMacambira
+    Revision:
+      moin--main--1.5--patch-473
+
+
+    new files:
+     contrib/stylesheets/.arch-ids/=id
+     contrib/stylesheets/.arch-ids/readme.txt.id
+     contrib/stylesheets/.arch-ids/speed.css.id
+     contrib/stylesheets/readme.txt contrib/stylesheets/speed.css
+
+    modified files:
+     ChangeLog MoinMoin/parser/rst.py docs/CHANGES
+
+    new directories:
+     contrib/stylesheets contrib/stylesheets/.arch-ids
+
+
 2006-03-08 22:30:00 GMT	Alexander Schremmer <alex@alexanderweb.de.tla>	patch-472
 
     Summary:
--- a/MoinMoin/parser/rst.py	Wed Mar 08 21:30:00 2006 +0000
+++ b/MoinMoin/parser/rst.py	Sun Mar 12 23:47:29 2006 +0000
@@ -243,6 +243,7 @@
         # function (see visit_image for an example).
         self.wiki_text = ''
         self.setup_wiki_handlers()
+        self.setup_admonitions_handlers()
         
         # Make all internal lists RawHTMLLists, see RawHTMLList class
         # comment for more information.
@@ -447,8 +448,6 @@
             'list_item': 'listitem',
             # Definition List
             'definition_list': 'definition_list',
-            # Admonitions
-            'warning': 'highlight'
         }
         for rest_func, moin_func in handlers.items():
             visit_func, depart_func = self.create_wiki_functor(moin_func)
@@ -468,6 +467,45 @@
         self.request.write(self.formatter.number_list(0))
         self.body.append(self.wiki_text)
 
+    # Admonitions are handled here -=- tmacam
+    def create_admonition_functor(self, admotion_class):
+        tag_class = 'admonition_' + admotion_class
+        def visit_func(self, node):
+            self.wiki_text = ''
+            self.request.write(self.formatter.div(1,
+                                                  attr={'class': tag_class},
+                                                  allowed_attrs=[]))
+            self.body.append(self.wiki_text)
+        def depart_func(self, node):
+            self.wiki_text = ''
+            self.request.write(self.formatter.div(0))
+            self.body.append(self.wiki_text)
+            
+        return visit_func, depart_func 
+
+    def setup_admonitions_handlers(self):
+        """
+            Admonitions are handled here... We basically surround admonitions
+            in a div with class admonition_{name of the admonition}.
+        """
+        handled_admonitions = [
+            'attention',
+            'caution',
+            'danger',
+            'error',
+            'hint',
+            'important',
+            'note',
+            'tip',
+            'warning',
+        ]
+        for adm in handled_admonitions:
+            visit_func, depart_func = self.create_admonition_functor(adm)
+            visit_func = new.instancemethod(visit_func, self, MoinTranslator)
+            depart_func = new.instancemethod(depart_func, self, MoinTranslator)
+            setattr(self, 'visit_%s' % (adm), visit_func)
+            setattr(self, 'depart_%s' % (adm), depart_func)
+
 
 class MoinDirectives:
     """
@@ -555,3 +593,4 @@
 
 if ErrorParser: # fixup in case of missing docutils
     Parser = ErrorParser
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/stylesheets/readme.txt	Sun Mar 12 23:47:29 2006 +0000
@@ -0,0 +1,2 @@
+speed.css - this file shows how admonitions in restructured text pages
+            can be styled with CSS classes
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/stylesheets/speed.css	Sun Mar 12 23:47:29 2006 +0000
@@ -0,0 +1,57 @@
+.admonition_attention, .admonition_caution, .admonition_danger, .admonition_error, .admonition_hint, .admonition_important, .admonition_note, .admonition_tip, .admonition_warning {
+	border: 1pt solid #AEBDCC;
+	border-color: black;
+	background-color: #F3F5F7;
+	padding: 5pt;
+	font-family: courier, monospace;
+
+	padding-left: 50px;
+	margin: 30pt;
+	background-repeat: no-repeat;
+	background-position: 10pt 50% ;
+	background-image: url("/wiki/modern/img/attention.png");
+
+	
+	/* begin css 3 or browser specific rules - do not remove!
+	see: http://forums.techguy.org/archive/index.php/t-249849.html */
+	white-space: pre-wrap;
+	word-wrap: break-word;
+	white-space: -moz-pre-wrap;
+	white-space: -pre-wrap;
+	white-space: -o-pre-wrap;
+	/* end css 3 or browser specific rules */
+
+}
+
+.admonition_warning, .admonition_error, .admonition_danger {
+	background-image: url("/wiki/modern/img/icon-error.png");
+	border-color: red;
+	background-color: #fcc;
+	border-width: 2px;
+}
+
+.admonition_tip, .admonition_hint {
+	background-image: url("/wiki/modern/img/idea.png");
+	border-color: orange;
+	background-color: lightyellow;
+}
+
+.admonition_note {
+	background-image: url("/wiki/modern/img/icon-info.png");
+	border-color: darkblue;
+}
+
+.admonition_attention, .admonition_caution {
+	background-image: url("/wiki/modern/img/alert.png");
+	border-color: red;
+	border-width: 2px;
+	background-color: #eee;
+	
+}
+
+
+
+
+
+
+
--- a/docs/CHANGES	Wed Mar 08 21:30:00 2006 +0000
+++ b/docs/CHANGES	Sun Mar 12 23:47:29 2006 +0000
@@ -80,6 +80,9 @@
     * ThemeBase (use by modern/rightsidebar): removed duplicate AttachFile from
       actions menu (we already have it in editbar)
 
+  Other:
+    * Added css classes for the rst admonitions. Thanks to TiagoMacambira!
+
 Version 1.5.2:
 
   New features: