Commits

gao shuai committed d140b8b

redirect to content page after modfiy

Comments (0)

Files changed (3)

                 CONTENT.header=header
                 CONTENT.footer=footer
                 CONTENT.put()
+                if self.POST["contentkey"]:
+                    self.redirect('/%s/%s'%(COLLECTION.url,CONTENT.url))
+                    return
     
 
         elif flag=="addcollection":
 #--------------------------------#
 #--------------------------------#
 
+class MainPage(yui.HtmlRequestHandler):
+    @yui.server_cache(CACHETIME, False)
+    def get(self):
+        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 CollectionPage(yui.HtmlRequestHandler):
     @yui.server_cache(CACHETIME, False)
-    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))
-
+    def get(self,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))
 
 class ContentPage(yui.HtmlRequestHandler):
     @yui.server_cache(CACHETIME, False)
                 path = os.path.join(os.path.dirname(__file__), 'tpl','css.css')
         self.write(template.render(path, template_values))
 application = yui.WsgiApplication([
-    ('/', CollectionPage),
+    ('/', MainPage),
     ('/__(.*)', CollectionPage),
     ('/404*', NotFound) ,
     ('/(.*)/(.*)', ContentPage),
       {% for COLLECTION in COLLECTIONS %}
 		<h2>--{{COLLECTION.url}}--</h2>
             {% for WORD in COLLECTION.content_set %}
- 			{% ifequal COLLECTION.url "default" %} <h3><a href="/{{WORD.url}}?mod=true">{{WORD.url}}</a></h3> {% endifequal %}
+ 			{% ifequal COLLECTION.url "default" %} <h3><a href="/{{WORD.url}}?mod=true">{{WORD.title}}</a></h3> {% endifequal %}
 			{% ifnotequal COLLECTION.url "default" %} <h3><a href="/{{COLLECTION.url}}/{{WORD.url}}?mod=true">{{WORD.title}}</a></h3> {% endifnotequal %}
             {% endfor %}
         {% endfor %}