Commits

gao shuai committed 18ecbb2

最终确定是用来方便前端开发的工具,
还缺少图片支持

  • Participants
  • Parent commits d665712

Comments (0)

Files changed (5)

                 self.redirect('/%s/%s'%(COLLECTION.url,CONTENT.url))
                 return
     
+    
+        elif flag=="addormodjs":
+            type='js'
+            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":
                 url=self.POST['url']
                 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')
+            elif CONTENT.type=='js':
+                path = os.path.join(os.path.dirname(__file__), 'tpl','modjs.html')
             COLLECTIONS=collection.all()
             template_values["COLLECTIONS"]=COLLECTIONS
         else:
             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'
+                self.header['Content-type'] = 'text/css; charset=UTF-8'
                 path = os.path.join(os.path.dirname(__file__), 'tpl','css.css')
+            elif CONTENT.type=='js':
+                self.header['Content-type'] = 'text/javascript; charset=UTF-8'
+                path = os.path.join(os.path.dirname(__file__), 'tpl','js.js')
         self.write(template.render(path, template_values))
 application = yui.WsgiApplication([
     ('/', MainPage),

File tpl/admin.html

 		</div>
       </fieldset><br />
     </div>
+	<div style="float:left;">
+      <fieldset>
+        <legend>↓增加JS↓</legend>
+        <form action="/admin/addormodjs" 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;">
       <fieldset>
         <legend>↓增加COLLECTION↓</legend>
+{{CONTENT.content}}

File tpl/modjs.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>
+      后台
+    </title>
+    <link href="/static/main.css" rel="stylesheet" type="text/css" media="all" />
+  </head>
+  <body>
+    {% include 'seo.html' %} {% include 'header.html' %} 
+    <div>
+      <fieldset>
+        <legend>↓编辑CSS↓</legend>
+        <form action="/admin/addormodjs" 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>
+		  <br />
+          {% endfor %}
+		<br />content<br />
+            <textarea rows="5" cols="40" name='content'>{{CONTENT.content|escape}}</textarea>
+
+          <br />url<br /><input type="text" name='url' value="{{CONTENT.url}}"/>
+
+		  <input type="hidden" name='contentkey'  value="{{CONTENT.key}}" />
+          <input type="submit" value="提交" />
+        </form>
+      </fieldset><br />
+    </div>
+
+{% include 'footer.html' %}
+  </body>
+</html>