diff options
author | 藍挺瑋 <lantw44@gmail.com> | 2012-12-20 14:04:37 +0800 |
---|---|---|
committer | LAN-TW <lantw44@xwinexp.tfcis.org> | 2012-12-20 14:04:37 +0800 |
commit | 1692a388b619bfc095d00fd4b4593001fb26a0c6 (patch) | |
tree | 53c05389ec4b57b31841c8de9d16362fe19546fc | |
parent | c5b2c15bb5faa5e769daeafc29034a9efdf627f1 (diff) | |
download | inccalendar-1692a388b619bfc095d00fd4b4593001fb26a0c6.tar.gz inccalendar-1692a388b619bfc095d00fd4b4593001fb26a0c6.tar.zst inccalendar-1692a388b619bfc095d00fd4b4593001fb26a0c6.zip |
為匯入和匯出的功能作準備
-rw-r--r-- | app.yaml | 4 | ||||
-rw-r--r-- | jinhtml/export.html | 15 | ||||
-rw-r--r-- | jinhtml/import.html | 15 | ||||
-rw-r--r-- | jinhtml/skel.html | 14 | ||||
-rw-r--r-- | main.py | 4 | ||||
-rw-r--r-- | port.py | 53 |
6 files changed, 99 insertions, 6 deletions
@@ -28,6 +28,10 @@ handlers: script: access.\1.app secure: always +- url: /port.* + script: port.app + secure: always + - url: /.* script: main.app secure: always diff --git a/jinhtml/export.html b/jinhtml/export.html new file mode 100644 index 0000000..4ae7c91 --- /dev/null +++ b/jinhtml/export.html @@ -0,0 +1,15 @@ +{% extends "jinhtml/skel.html" %} +{% block headcss %} +{% endblock %} + +{% block onload %} + var switchmonthobj = document.getElementById("buttonexport"); + switchmonthobj.className += "selected"; + switchmonthobj.onclick = ""; +{% endblock %} + +{% block headjs %} +{% endblock %} + +{% block body %} +{% endblock %} diff --git a/jinhtml/import.html b/jinhtml/import.html new file mode 100644 index 0000000..629e449 --- /dev/null +++ b/jinhtml/import.html @@ -0,0 +1,15 @@ +{% extends "jinhtml/skel.html" %} +{% block headcss %} +{% endblock %} + +{% block onload %} + var switchmonthobj = document.getElementById("buttonimport"); + switchmonthobj.className += "selected"; + switchmonthobj.onclick = ""; +{% endblock %} + +{% block headjs %} +{% endblock %} + +{% block body %} +{% endblock %} diff --git a/jinhtml/skel.html b/jinhtml/skel.html index c451f56..b9c071c 100644 --- a/jinhtml/skel.html +++ b/jinhtml/skel.html @@ -16,10 +16,16 @@ window.location = "{{ logouturl }}"; } function switch_month(){ - window.location = "{{ mysimple }}?view=month"; + window.location = "{{ myhost }}?view=month"; } function switch_list(){ - window.location = "{{ mysimple }}?view=list"; + window.location = "{{ myhost }}?view=list"; + } + function switch_import(){ + window.location = "{{ myhost }}/port?function=import" + } + function switch_export(){ + window.location = "{{ myhost }}/port?function=export" } window.onload = function(){ status_bar_init(); @@ -38,8 +44,8 @@ <input type="button" value="清單" id="switchlist" onclick="switch_list()"> </div> <div id="controlright"> - <input type="button" value="匯入" id="buttonimport"> - <input type="button" value="匯出" id="buttonexport"> + <input type="button" value="匯入" id="buttonimport" onclick="switch_import()"> + <input type="button" value="匯出" id="buttonexport" onclick="switch_export()"> <input type="button" value="登出" id="googlelogout" onclick="google_logout()" style="background-color: darkgray"> </div> </div> @@ -14,7 +14,7 @@ class MainPage(webapp2.RedirectHandler): guserid = users.get_current_user() productname = cgi.escape(u'#include <行事曆.h>') myurl = self.request.uri - mysimple = self.request.path_url + myhost = self.request.host_url useview = self.request.get('view') if guserid: logouturl = cgi.escape(users.create_logout_url(myurl)) @@ -22,7 +22,7 @@ class MainPage(webapp2.RedirectHandler): 'logouturl': logouturl, 'productname': productname, 'googleuser': guserid, - 'mysimple': mysimple + 'myhost': myhost } if not useview: @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +import cgi +import os +import jinja2 +import webapp2 + +from google.appengine.api import users +from google.appengine.ext import db + +class PortPage(webapp2.RedirectHandler): + def get(self): + guserid = users.get_current_user() + productname = cgi.escape(u'#include <行事曆.h>') + myurl = self.request.uri + myhost = self.request.host_url + usefunc = self.request.get('function') + if guserid: + logouturl = cgi.escape(users.create_logout_url(myurl)) + jintemvar = { + 'logouturl': logouturl, + 'productname': productname, + 'googleuser': guserid, + 'myhost': myhost + } + + if not usefunc: + usefunc = "import" + + if usefunc == "import": + jinhtml = jinenv.get_template('jinhtml/import.html') + elif usefunc == "export": + jinhtml = jinenv.get_template('jinhtml/export.html') + else: + self.response.set_status(404) + return + + else: + loginurl = cgi.escape(users.create_login_url(myhost)) + jintemvar = { + 'loginurl': loginurl, + 'productname': productname + } + jinhtml = jinenv.get_template('jinhtml/welcome.html') + + self.response.out.write(jinhtml.render(jintemvar)) + + +jinenv = jinja2.Environment( + loader = jinja2.FileSystemLoader(os.path.dirname(__file__))) + +app = webapp2.WSGIApplication([('/port', PortPage)]) |