[gimp-web/gimp-web-static] Fixed a small problem with page rendering and not showing



commit 60c78099a505bf07acf661fb87ac6da40b47eddc
Author: Pat David <patdavid gmail com>
Date:   Wed Aug 5 16:30:13 2015 -0500

    Fixed a small problem with page rendering and not showing
    
    If the page status was set as "Status: hidden" it technically
    didn't have a 'parent' object and was breaking the build.

 content/about/ancient_history.md              |    5 +++--
 pelicanconf.py                                |    9 +++++----
 plugins/page_hierarchy_gimp/page_hierarchy.py |   20 +++++++++++++++-----
 themes/newgimp/templates/page.html            |    2 ++
 4 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/content/about/ancient_history.md b/content/about/ancient_history.md
index e269483..2e0f929 100644
--- a/content/about/ancient_history.md
+++ b/content/about/ancient_history.md
@@ -3,8 +3,9 @@ Date: 2015-07-29T14:40:35-05:00
 Modified: 2015-07-29T14:40:43-05:00
 Authors: Pat David
 Summary: About the folks behind this project.
-url: about/ancient_history.html
-save_as: about/ancient_history.html
+
+#url: about/ancient_history.html
+#save_as: about/ancient_history.html
 
 ## A Brief History of GIMP
 
diff --git a/pelicanconf.py b/pelicanconf.py
index e197a97..3ae80ce 100644
--- a/pelicanconf.py
+++ b/pelicanconf.py
@@ -46,7 +46,7 @@ DEFAULT_PAGINATION = False
 STATIC_PATHS = ['images', 'pages', 'tutorials', 'about']
 
 #PAGE_PATHS = ['pages', 'tutorials', 'about']
-PAGE_PATHS = ['tutorials', 'about']
+PAGE_PATHS = ['about', 'tutorials']
 
 THEME = "./themes/newgimp"
 
@@ -54,8 +54,8 @@ THEME = "./themes/newgimp"
 #PATH_METADATA = r".*?\\(?P<test>.*?\\)" #old test
 #see: https://github.com/getpelican/pelican/issues/1128#issuecomment-63251758
 #PATH_METADATA = r'.*?\\(?P<test>(.+\\)?).*' 
-PATH_METADATA = r'(?P<test>.*/)'
-PATH_METADATA = r'(?P<test>.*\\)'
+#PATH_METADATA = r'(?P<test>.*/)'
+#PATH_METADATA = r'(?P<test>.*\\)'
 
 
 # Still working on this...
@@ -63,7 +63,8 @@ PATH_METADATA = r'(?P<test>.*\\)'
 #PAGE_SAVE_AS = "{test}{slug}/index.html"
 
 PAGE_URL = "{slug}/"
-PAGE_SAVE_AS = "{slug}/index.html"
+#PAGE_SAVE_AS = "{slug}/index.html"
+PAGE_SAVE_AS = "{slug}/{filename}"
 
 ARTICLE_URL = "news/{date:%Y}/{date:%m}/{date:%d}/{slug}/"
 ARTICLE_SAVE_AS = "news/{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html"
diff --git a/plugins/page_hierarchy_gimp/page_hierarchy.py b/plugins/page_hierarchy_gimp/page_hierarchy.py
index d917266..a6ecb9a 100644
--- a/plugins/page_hierarchy_gimp/page_hierarchy.py
+++ b/plugins/page_hierarchy_gimp/page_hierarchy.py
@@ -1,5 +1,6 @@
 from pelican import signals, contents
 import os.path
+from os.path import basename
 from copy import copy
 from itertools import chain
 
@@ -34,12 +35,12 @@ def override_metadata(content_object):
     if type(content_object) is not contents.Page:
         return
     page = content_object
-    print( "page.get_relative_source_path():" )
     print( "####################" )
+    print( "page.get_relative_source_path():" )
     print( page.get_relative_source_path() )
     print( "####################" )
-    print( "manual path:" )
-    print( os.path.split(page.get_relative_source_path())[0] )
+    print( "manual path [1]:" )
+    print( os.path.split(page.get_relative_source_path())[1] )
     #path = get_path(page, page.settings)
     path = os.path.split(page.get_relative_source_path())[0]
     path = path.replace( os.path.sep, '/' )
@@ -54,8 +55,11 @@ def override_metadata(content_object):
         print( page.slug )
         print( "_override_value, metadata['slug']:")
         print( metadata['slug'] )
-        print( "_override_value, metadata['slug'] (2):")
-        print( metadata['slug'] )
+
+        metadata['filename'] = os.path.split(page.get_relative_source_path())[1]
+        metadata['filename'] = os.path.splitext( metadata['filename'])[0] + '.html'
+        print( "metadata['filename']:" )
+        print( metadata['filename'] )
 
         # PLD: this is my doing, sorry...
         # ok, if path is empty, use page.slug
@@ -70,6 +74,9 @@ def override_metadata(content_object):
             print( page.slug )
             metadata['slug'] = page.slug
 
+        if metadata['filename'] != 'index.html':
+            setattr(page, 'override_url', metadata['slug'] +'/'+ metadata['filename'] )
+
         # We have to account for non-default language and format either,
         # e.g., PAGE_SAVE_AS or PAGE_LANG_SAVE_AS
         infix = '' if in_default_lang(page) else 'LANG_'
@@ -78,6 +85,9 @@ def override_metadata(content_object):
     for key in ('save_as', 'url'):
         if not hasattr(page, 'override_' + key):
             setattr(page, 'override_' + key, _override_value(page, key))
+        print( "## page.url ##" )
+        print( page.url )
+        
 
 def set_relationships(generator):
     def _all_pages():
diff --git a/themes/newgimp/templates/page.html b/themes/newgimp/templates/page.html
index 142c92d..e9de7c5 100644
--- a/themes/newgimp/templates/page.html
+++ b/themes/newgimp/templates/page.html
@@ -38,9 +38,11 @@
                 url: {{ page.url }} <br/>
                 metadata regex test: {{ page.test }}<br/>
                 slug: {{ page.slug }}<br/>
+                {% if page.parent %}
                 page parent: {{ page.parent }}<br/>
                 page parent url: {{ page.parent.url }} <br/>
                 page parent title: {{ page.parent.title }}
+                {% endif %}
             </p>
         
             <p>page parents</p>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]