slowniczek link
[librarian.git] / librarian / pyhtml.py
index d138701..b4d8557 100644 (file)
@@ -9,6 +9,7 @@ from xmlutils import Xmill, tag, tagged, ifoption, tag_open_close
 from librarian import functions
 import re
 import random
+from copy import deepcopy
 
 IMAGE_THUMB_WIDTH = 300
 
@@ -150,16 +151,24 @@ u"""%(wskazowki)s
     # Lists
     def handle_lista(self, element, attrs={}):
         ltype = element.attrib.get('typ', 'punkt')
+        if not element.findall("punkt"):
+            if ltype == 'czytelnia':
+                return '<p>W przygotowaniu.</p>'
+            else:
+                return None
         if ltype == 'slowniczek':
             surl = element.attrib.get('src', None)
             if surl is None:
                 # print '** missing src on <slowniczek>, setting default'
-                surl = 'http://edukacjamedialna.edu.pl/slowniczek'
+                surl = 'http://edukacjamedialna.edu.pl/lekcje/slowniczek/'
             sxml = None
             if surl:
                 sxml = etree.fromstring(self.options['provider'].by_uri(surl).get_string())
             self.options = {'slowniczek': True, 'slowniczek_xml': sxml }
-            return '<div class="slowniczek">', '</div>'
+            pre, post = '<div class="slowniczek">', '</div>'
+            if self.options['wldoc'].book_info.url.slug != 'slowniczek':
+                post += u'<p class="see-more"><a href="%s">Zobacz cały słowniczek.</a></p>' % surl
+            return pre, post
 
         listtag = {'num': 'ol',
                'punkt': 'ul',
@@ -444,12 +453,10 @@ class Luki(Exercise):
         return question.xpath(".//luka")
 
     def solution_html(self, piece):
+        piece = deepcopy(piece)
+        piece.tail = None
         sub = EduModule()
         return sub.generate(piece)
-        # print piece.text
-        # return piece.text + ''.join(
-        #     [etree.tostring(n, encoding=unicode)
-        #      for n in piece])
 
     def handle_pytanie(self, element):
         qpre, qpost = super(Luki, self).handle_pytanie(element)