Kaynağa Gözat

render pages to the correct location

Oz N Tiram 9 yıl önce
ebeveyn
işleme
8da0acdf18
2 değiştirilmiş dosya ile 14 ekleme ve 23 silme
  1. 12 19
      blogit/blogit.py
  2. 2 4
      conf.py

+ 12 - 19
blogit/blogit.py

@@ -186,8 +186,12 @@ class Entry(object):
 
     @property
     def destination(self):
-        dest = "%s/%s/index.html" % (KINDS[
-                                     self.kind]['name_plural'], self.name)
+        # pages are rendered to the top level
+        if self.kind == 'page':
+            dest = '%s.html' % self.title.replace('/', "-")
+        else:
+            dest = "%s/%s/index.html" % (KINDS[self.kind]['name_plural'], self.name)
+            dest = dest.lstrip('/')
         print dest
         return os.path.join(CONFIG['output_to'], dest)
 
@@ -230,20 +234,9 @@ class Entry(object):
 
     @property
     def body_html(self):
-        if renderer == 'md2':
-            return markdown2.markdown(self.body, extras=['fenced-code-blocks',
-                                                         'hilite',
-                                                         'tables'])
-        if renderer == 'md1':
-            return markdown.markdown(self.body,
-                                     extensions=['fenced_code',
-                                                 'codehilite(linenums=False)',
-                                                 'tables'])
-
-    @property
-    def permalink(self):
-        return "/%s/%s" % (KINDS[self.kind]['name_plural'], self.name)
-
+        return markdown2.markdown(self.body, extras=['fenced-code-blocks',
+                                                     'hilite',
+                                                     'tables'])
     @property
     def tags(self):
         try:
@@ -299,8 +292,9 @@ class Entry(object):
             print self.path
             print e
             sys.exit()
-        destination = codecs.open(
-            self.destination, 'w', CONFIG['content_encoding'])
+
+        destination = codecs.open(self.destination, 'w',
+                                  CONFIG['content_encoding'])
         destination.write(html)
         destination.close()
 
@@ -415,7 +409,6 @@ def new_build():
     c. update archive page
 
     """
-    # TODO: slug each page to it's unique location
     print
     print "Rendering website now..."
     print

+ 2 - 4
conf.py

@@ -54,6 +54,8 @@ GLOBAL_TEMPLATE_CONTEXT = {
     'github': "https://github.com/oz123",
 }
 
+
+# with this config, pages are rendered to the location of their title
 KINDS = {
     'writing': {
         'name': 'writing', 'name_plural': 'writings',
@@ -67,8 +69,4 @@ KINDS = {
     'photo': {
         'name': 'photo', 'name_plural': 'photos',
     },
-    'page': {
-        'name': 'page', 'name_plural': 'pages',
-    },
-
 }