Commits

gao shuai committed b488e26

css

  • Participants
  • Parent commits fde632a

Comments (0)

Files changed (6)

 class CollectionHandler(yui.RequestHandler):
 #    @yui.authorized(False)
     def post(self,flag):
-        if flag=="addormodhtmlorcss":
-            type=self.POST['type']
-            if type!="":
-                tcontent=self.POST['content']
-                head=self.POST['head']
-                url=self.POST['url']
-                title=self.POST['title']
-                examkey=self.POST['examkey']
-                if self.POST['header']=="true":
-                    header=True
-                else:
-                    header=False
-                if self.POST['footer']=="true":
-                    footer=True
-                else:
-                    footer=False
-                COLLECTION=db.get(examkey)
-                if self.POST["contentkey"]:
-                    CONTENT=db.get(self.POST["contentkey"])
-                else:
-                    CONTENT=content()
-                CONTENT.user=COLLECTION
-                CONTENT.time=getCNnow()
-                CONTENT.content=tcontent
-                CONTENT.head=head
-                CONTENT.url=url
-                CONTENT.title=title
-                CONTENT.type=type
-                CONTENT.header=header
-                CONTENT.footer=footer
-                CONTENT.put()
-                if self.POST["contentkey"]:
-                    self.redirect('/%s/%s'%(COLLECTION.url,CONTENT.url))
-                    return
+        if flag=="addormodhtml":
+            type='html'
+            tcontent=self.POST['content']
+            head=self.POST['head']
+            url=self.POST['url']
+            title=self.POST['title']
+            examkey=self.POST['examkey']
+            if self.POST['header']=="true":
+                header=True
+            else:
+                header=False
+            if self.POST['footer']=="true":
+                footer=True
+            else:
+                footer=False
+            COLLECTION=db.get(examkey)
+            if self.POST["contentkey"]:
+                CONTENT=db.get(self.POST["contentkey"])
+            else:
+                CONTENT=content()
+            CONTENT.user=COLLECTION
+            CONTENT.time=getCNnow()
+            CONTENT.content=tcontent
+            CONTENT.head=head
+            CONTENT.url=url
+            CONTENT.title=title
+            CONTENT.type=type
+            CONTENT.header=header
+            CONTENT.footer=footer
+            CONTENT.put()
+            if self.POST["contentkey"]:
+                self.redirect('/%s/%s'%(COLLECTION.url,CONTENT.url))
+                return
+    
+        elif flag=="addormodcss":
+            type='css'
+            tcontent=self.POST['content']
+            url=self.POST['url']
+            title=url
+            examkey=self.POST['examkey']
+            COLLECTION=db.get(examkey)
+            if self.POST["contentkey"]:
+                CONTENT=db.get(self.POST["contentkey"])
+            else:
+                CONTENT=content()
+            CONTENT.user=COLLECTION
+            CONTENT.time=getCNnow()
+            CONTENT.content=tcontent
+            CONTENT.head=''
+            CONTENT.url=url
+            CONTENT.title=title
+            CONTENT.type=type
+            CONTENT.header=False
+            CONTENT.footer=False
+            CONTENT.put()
+            if self.POST["contentkey"]:
+                self.redirect('/%s/%s'%(COLLECTION.url,CONTENT.url))
+                return
     
 
         elif flag=="addcollection":
 
         }
         if self.GET["mod"]=="true":
-            path = os.path.join(os.path.dirname(__file__), 'tpl','mod.html')
+            if CONTENT.type=='html' or CONTENT.type==None:
+                path = os.path.join(os.path.dirname(__file__), 'tpl','mod.html')
+            elif CONTENT.type=='css':
+                path = os.path.join(os.path.dirname(__file__), 'tpl','modcss.html')
             COLLECTIONS=collection.all()
             template_values["COLLECTIONS"]=COLLECTIONS
         else:
-            if CONTENT.type=='html' or COLLECTION.type==None:
+            if CONTENT.type=='html' or CONTENT.type==None:
                 path = os.path.join(os.path.dirname(__file__), 'tpl','html.html')
             elif CONTENT.type=='css':
+                self.header['Content-type'] = 'text/css'
                 path = os.path.join(os.path.dirname(__file__), 'tpl','css.css')
         self.write(template.render(path, template_values))
 application = yui.WsgiApplication([

File static/main.css

 	font-size:12px;
 	color:#666;
 }
+#explain{
+	text-align:center;
+	margin:20px 10px;
+	font-size:12px;
+	color:#666;
+}
 
 legend {
 	color:#06c;
-	margin:20px 10px;
+	margin:20px 20px;
 	font-weight:800;
 	background:#fff;
 	border:#b6b6b6 solid 1px;
 }
 fieldset {
 	color:#06c;
-	margin:40px 40px;
-	font-weight:800;
+	margin:30px 40px;
 	background:#fff;
 	border:#b6b6b6 solid 1px;
 	padding:3px 6px;

File tpl/admin.html

     {% include 'seo.html' %} {% include 'header.html' %}
     <div style="float:left;">
       <fieldset>
-        <legend>↓增加HTML/CSS↓</legend>
-        <form action="/admin/addormodhtmlorcss" method="post">
-          {% for COLLECTION in COLLECTIONS %} <input type="radio" name='examkey' checked="checked"
-          value="{{COLLECTION.key}}" /> <a href="/{{COLLECTION.url}}">{{COLLECTION.url}}</a><br />
+        <legend>↓增加HTML↓</legend>
+        <form action="/admin/addormodhtml" method="post">
+          <br />COLLECTION <br />{% for COLLECTION in COLLECTIONS %} <input type="radio" name='examkey' {% ifequal COLLECTION.url 'default' %} checked="checked" {% endifequal  %}
+          value="{{COLLECTION.key}}" /> <a href="/__{{COLLECTION.url}}">{{COLLECTION.url}}</a><br />
           {% endfor %}
-          <div>
-            <textarea rows="5" cols="40" name='head'>
-</textarea>head 
-            <textarea rows="5" cols="40" name='content'>
-</textarea>content
-          </div><input type="text" name='title' />title<br />
-          <input type="text" name='url' />url<br />
-          <input type="radio" name='type' value="html" checked="checked" />html<br />
-          <input type="radio" name='type' value="css" />css<br />
+          <br />url<br /><input type="text" name='url' /><br />
           <input type="checkbox" name='header' checked="checked" value="true" />header<br />
           <input type="checkbox" name='footer' checked="checked" value="true" />footer<br />
+		  <br />title<br /><input type="text" name='title' />
+          <div>
+            <br />head<br /><textarea rows="5" cols="30" name='head'>
+</textarea> 
+            <br />body<br /><textarea rows="10" cols="30" name='content'>
+</textarea>
+          </div>
           <input type="submit" value="提交" />
         </form>
+		<div id="explain">
+<pre>
+说明:
+	header 页面上方的导航栏
+	footer 页面下方的版权说明
+
+</pre>
+		</div>
+      </fieldset><br />
+    </div>
+	<div style="float:left;">
+      <fieldset>
+        <legend>↓增加CSS↓</legend>
+        <form action="/admin/addormodcss" method="post">
+          <br />COLLECTION <br />{% for COLLECTION in COLLECTIONS %} <input type="radio" name='examkey' {% ifequal COLLECTION.url 'default' %} checked="checked" {% endifequal  %}
+          value="{{COLLECTION.key}}" /> <a href="/__{{COLLECTION.url}}">{{COLLECTION.url}}</a><br />
+          {% endfor %}
+          <br />url<br /><input type="text" name='url' />
+            <br />content <br /><textarea rows="20" cols="30" name='content'>
+</textarea><br />
+
+          <input type="submit" value="提交" />
+        </form>
+		<div id="explain">
+		<p>说明</p>
+		</div>
       </fieldset><br />
     </div>
     <div style="float:left;">
           <input type="text" name='url' />url<br />
           <input type="submit" value="提交" />
         </form>
-      </fieldset><br />
+		<div id="explain">
+		<p>说明</p>
+		</div>
+      </fieldset>
     </div>
-    <div id="pageurls">
-      <ul>
-        <li class="c1">
-          <h2>
-            {{COLLECTION.url}}
-          </h2>{% for WORD in COLLECTION.content_set %}
-        </li>
-        <li>
-          <a href="/{{COLLECTION.url}}/{{WORD.url}}">{{WORD.title}}</a>
-        </li>
-        <li class="c1">{% endfor %}
-        </li>
-      </ul>
-    </div>
+    <fieldset>
+        <legend>↓编辑HTML/CSS↓</legend>
     <div id="collectionurls">
 
         {% for COLLECTION in COLLECTIONS %}
               
            
           </div>{% endfor %}
-        
-      
-    </div>{% include 'footer.html' %}
+    </div>
+		<div id="explain">
+		<p>说明</p>
+		</div>
+	 </fieldset>
+	 {% include 'footer.html' %}
   </body>
 </html>

File tpl/header.html

 <div id="header"> 
 <a href='/'>HOME</a>
 <a href='/admin'>ADMIN</a>
+<a href='/about'>ABOUT</a>
 <hr />
 </div>
 

File tpl/mod.html

     <div>
       <fieldset>
         <legend>↓编辑HTML/CSS↓</legend>
-        <form action="/admin/addormodhtmlorcss" method="post">
+        <form action="/admin/addormodhtml" method="post">
 		  {% for C in COLLECTIONS %} 
-		  <input type="radio" name='examkey' {% ifequal C.url COLLECTION.url %} checked="checked" {% endifequal %}value="{{C.key}}" /> <a href="/{{C.url}}">{{C.url}}</a>
+		  <input type="radio" name='examkey' {% ifequal C.url COLLECTION.url %} checked="checked" {% endifequal %}value="{{C.key}}" /> <a href="/__{{C.url}}">{{C.url}}</a>
 		  <br />
           {% endfor %}
           <div>