Commits

gao shuai  committed d4f9f34

mainpage

  • Participants
  • Parent commits b8d4b0d

Comments (0)

Files changed (3)

 #--------------------------------#
 #--------------------------------#
 
-class ColectionPage(yui.HtmlRequestHandler):
+class CollectionPage(yui.HtmlRequestHandler):
     @yui.server_cache(CACHETIME, False)
-    def get(self):
-        try:
-            COLLECTIONS=collection.all().order("-time")
-
-        except IndexError:
-            COLLECTIONS=None
-
-        template_values = {
-        'COLLECTIONS':COLLECTIONS,
-
-        }
-
-        path = os.path.join(os.path.dirname(__file__), 'tpl','collectionpage.html')
-
-        self.write(template.render(path, template_values))
+    def get(self,collectionUrl=None):
+        if collectionUrl:
+            try: 
+                COLLECTION=db.GqlQuery("SELECT * FROM collection WHERE url = :1",collectionUrl)[0]
+            except IndexError:
+                COLLECTION=None
+            template_values = {
+            'COLLECTION':COLLECTION,
+            }
+            path = os.path.join(os.path.dirname(__file__), 'tpl','collectionpage.html')
+            self.write(template.render(path, template_values))
+        else:
+            try: 
+                DEFAULT=db.GqlQuery("SELECT * FROM collection WHERE url = :1","default")[0]
+                COLLECTIONS=collection.all().order("-time")
+            except IndexError:
+                COLLECTIONS=None
+            template_values = {
+            'DEFAULT':DEFAULT,
+            'COLLECTIONS':COLLECTIONS,
+            }
+            path = os.path.join(os.path.dirname(__file__), 'tpl','mainpage.html')
+            self.write(template.render(path, template_values))
 
 
 class ContentPage(yui.HtmlRequestHandler):
                 path = os.path.join(os.path.dirname(__file__), 'tpl','css.css')
         self.write(template.render(path, template_values))
 application = yui.WsgiApplication([
-    ('/', ColectionPage),
+    ('/', CollectionPage),
+    ('/__(.*)', CollectionPage),
     ('/404*', NotFound) ,
     ('/(.*)/(.*)', ContentPage),
     ('/(.*)', ContentPage),

File tpl/collectionpage.html

     {% include 'seo.html' %} {% include 'header.html' %} 
 
 
-      {% for COLLECTION in COLLECTIONS %}
+
 		<h2>{{COLLECTION.url}}</h2>
             {% for WORD in COLLECTION.content_set %} 
-			{% ifequal COLLECTION.url "default" %} <h3><a href="/{{WORD.url}}">{{WORD.title}}</a></h3> {% endifequal %}
-			{% ifnotequal COLLECTION.url "default" %} <h3><a href="/{{COLLECTION.url}}/{{WORD.url}}">{{WORD.title}}</a></h3> {% endifnotequal %}
-			
+			<h3><a href="/{{COLLECTION.url}}/{{WORD.url}}">{{WORD.title}}</a></h3>
+
             {% endfor %}
-        {% endfor %}
+
 
 
 	{% include 'footer.html' %}

File tpl/mainpage.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
+    <title>
+      CMS
+    </title>
+	<link href="/static/main.css" rel="stylesheet" type="text/css" media="all" />
+  </head>
+  <body>
+    {% include 'seo.html' %} {% include 'header.html' %} 
+      {% for PAGE in DEFAULT.content_set %}
+		<h3><a href="/{{PAGE.url}}">{{PAGE.title}}</a></h3>
+        {% endfor %}
+<hr />
+      {% for COLLECTION in COLLECTIONS %}
+		<h3><a href="/__{{COLLECTION.url}}">{{COLLECTION.url}}</a></h3>
+        {% endfor %}
+
+
+	{% include 'footer.html' %}
+  </body>
+</html>