Skip to content

Commit

Permalink
1.13.3-beta
Browse files Browse the repository at this point in the history
Seperation of front-end and backend finished
  • Loading branch information
rexdf committed Apr 8, 2014
1 parent 0187b7b commit bff1db2
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ handlers:
script: handlemail.appmail

- url: /.*
script: main.app
script: apps.module_front.app

2 changes: 1 addition & 1 deletion apps/BaseHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from google.appengine.runtime.apiproxy_errors import (OverQuotaError,
DeadlineExceededError)

import main
#import main

class BaseHandler:
" URL请求处理类的基类,实现一些共同的工具函数 "
Expand Down
2 changes: 1 addition & 1 deletion apps/View/Admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from config import *

import main
#import main

class Admin(BaseHandler):
__url__ = "/admin"
Expand Down
2 changes: 1 addition & 1 deletion apps/View/Login.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from config import *

import main
#import main

class Login(BaseHandler):
__url__ = "/login"
Expand Down
2 changes: 1 addition & 1 deletion apps/View/Setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from config import *

import main
#import main

class Setting(BaseHandler):
__url__ = "/setting"
Expand Down
2 changes: 1 addition & 1 deletion apps/View/Share.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from bs4 import BeautifulSoup
from books.base import BaseUrlBook

import main
#import main

class Share(BaseHandler):
""" 保存到evernote或分享到社交媒体 """
Expand Down
2 changes: 1 addition & 1 deletion apps/View/Subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from apps.BaseHandler import BaseHandler
from apps.dbModels import *

import main
#import main

class MySubscription(BaseHandler):
__url__ = "/my"
Expand Down
2 changes: 1 addition & 1 deletion apps/View/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pkgutil
import inspect

import main
#import main

#Load all class with __url__ attribute in the directory

Expand Down
2 changes: 1 addition & 1 deletion apps/Work/Url2Book.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from books.base import BaseUrlBook

import main
#import main

class Url2Book(BaseHandler):
""" 抓取指定链接,转换成附件推送 """
Expand Down
2 changes: 1 addition & 1 deletion apps/Work/Worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from books import BookClasses, BookClass
from books.base import BaseFeedBook

import main
#import main

class Worker(BaseHandler):
""" 实际下载文章和生成电子书并且发送邮件 """
Expand Down
2 changes: 1 addition & 1 deletion apps/Work/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pkgutil
import inspect

import main
#import main

#Load all class with __url__ attribute in the directory

Expand Down
26 changes: 21 additions & 5 deletions main.py → apps/module_backend.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
supported_languages = ['en','zh-cn','tr-tr'] #不支持的语种则使用第一个语言
#gettext.install('lang', 'i18n', unicode=True) #for calibre startup

class Main_Var:
urls = []
session = None
jjenv = None
supported_languages = None
log = None
__Version__ = None

__builtin__.__dict__['main'] = Main_Var
main.supported_languages = supported_languages
main.log = log
main.__Version__ = __Version__

import web
import jinja2
#from google.appengine.api import mail
Expand All @@ -30,11 +43,11 @@
from lib.memcachestore import MemcacheStore
from books import BookClasses

from apps.Work import *

from apps.dbModels import Book
from apps.BaseHandler import BaseHandler
from apps.utils import fix_filesizeformat
from apps.View import *
from apps.Work import *

#reload(sys)
#sys.setdefaultencoding('utf-8')
Expand All @@ -57,9 +70,9 @@ def GET(self):
s += "<pre><p>" + str(d).rjust(28) + " | " + str(os.environ[d]) + "</p></pre>"
return s

urls += ["/test", "Test",]
main.urls += ["/test", "Test",]

application = web.application(urls, globals())
application = web.application(main.urls, globals())
store = MemcacheStore(memcache)
session = web.session.Session(application, store, initializer={'username':'','login':0,"lang":''})
jjenv = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'),
Expand All @@ -68,4 +81,7 @@ def GET(self):

app = application.wsgifunc()

web.config.debug = IsRunInLocal
web.config.debug = IsRunInLocal

main.session = session
main.jjenv = jjenv
87 changes: 87 additions & 0 deletions apps/module_front.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#A GAE web application to aggregate rss and send it to your kindle.
#Visit https://github.com/cdhigh/KindleEar for the latest version
#中文讨论贴:http://www.hi-pda.com/forum/viewthread.php?tid=1213082
#Contributors:
# rexdf <https://github.com/rexdf>

__Version__ = "1.13.3-beta"
__Author__ = "cdhigh"

import os, datetime, logging, __builtin__, hashlib, time

# for debug
# 本地启动调试服务器:python.exe dev_appserver.py c:\kindleear
IsRunInLocal = (os.environ.get('SERVER_SOFTWARE', '').startswith('Development'))
log = logging.getLogger()
__builtin__.__dict__['default_log'] = log
__builtin__.__dict__['IsRunInLocal'] = IsRunInLocal

supported_languages = ['en','zh-cn','tr-tr'] #不支持的语种则使用第一个语言
#gettext.install('lang', 'i18n', unicode=True) #for calibre startup

class Main_Var:
urls = []
session = None
jjenv = None
supported_languages = None
log = None
__Version__ = None

__builtin__.__dict__['main'] = Main_Var
main.supported_languages = supported_languages
main.log = log
main.__Version__ = __Version__

import web
import jinja2
#from google.appengine.api import mail
from google.appengine.api import taskqueue
from google.appengine.api import memcache

from lib.memcachestore import MemcacheStore
from books import BookClasses

from apps.View import *

from apps.dbModels import Book
from apps.BaseHandler import BaseHandler
from apps.utils import fix_filesizeformat

#reload(sys)
#sys.setdefaultencoding('utf-8')

log.setLevel(logging.INFO if IsRunInLocal else logging.WARN)

for book in BookClasses(): #添加内置书籍
if memcache.get(book.title): #使用memcache加速
continue
b = Book.all().filter("title = ", book.title).get()
if not b:
b = Book(title=book.title,description=book.description,builtin=True)
b.put()
memcache.add(book.title, book.description, 86400)

class Test(BaseHandler):
def GET(self):
s = ''
for d in os.environ:
s += "<pre><p>" + str(d).rjust(28) + " | " + str(os.environ[d]) + "</p></pre>"
return s

main.urls += ["/test", "Test",]

application = web.application(main.urls, globals())
store = MemcacheStore(memcache)
session = web.session.Session(application, store, initializer={'username':'','login':0,"lang":''})
jjenv = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'),
extensions=["jinja2.ext.do",'jinja2.ext.i18n'])
jjenv.filters['filesizeformat'] = fix_filesizeformat

app = application.wsgifunc()

web.config.debug = IsRunInLocal

main.session = session
main.jjenv = jjenv
2 changes: 1 addition & 1 deletion apps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import gettext
import re

import main
#import main

def local_time(fmt="%Y-%m-%d %H:%M", tz=TIMEZONE):
return (datetime.datetime.utcnow()+datetime.timedelta(hours=tz)).strftime(fmt)
Expand Down
2 changes: 1 addition & 1 deletion module-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ handlers:
script: handlemail.appmail

- url: /.*
script: main.app
script: apps.module_backend.app

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Update-logs & Roadmap #

**note: both app.yaml & module-worker.yaml require application id
**note: Both app.yaml & module-worker.yaml require application id
and use upload.sh or upload.bat to deploy module**
(You need to set application to F1 in Application settings/Performance/Frontend Instance Class)

Expand Down
2 changes: 1 addition & 1 deletion upload.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appcfg.py update app.yaml module-worker.yaml
appcfg.py update app.yaml module-front.yaml module-worker.yaml
appcfg.py update .

0 comments on commit bff1db2

Please sign in to comment.