Esempio n. 1
0
def user_work_experience_post_page():
    """
    用户的工作经历
    """

    data = {}
    user = g.curr_user
    page_form = PageForm()
    form = UserWorkExperienceForm()

    data['page_form'] = page_form
    data['form'] = form

    data['is_error'] = False
    if form.validate():
        #如果提交成功就跳转到get请求上
        #防治用户通过F5刷新重复提交 Post-Redirect-Get (PRG)模式。
        work = add_user_work_experiences(user, form.company_name.data, form.position.data,
                                         form.department.data, form.entry_at.data,
                                         is_resign=form.is_resign.data, dimission_at=form.dimission_at.data,
                                         company_id=form.company_id.data)
        to_redirect = redirect(url_for('user_page.user_work_experience_page'))
        return to_redirect
    else:
        data['is_error'] = True

    works, pages = find_user_work_experiences(user, limit=page_form.l.data, page=page_form.p.data)
    data['works'] = works
    data['pages'] = pages
    return render('/user/work.html', **data)
Esempio n. 2
0
 def GET(self):
     """系统设置表单"""
     import pytz
     common_timezones = pytz.common_timezones
     blog = Blog.get()
     
     return render('admin/setting.html',blog=blog,timezones=common_timezones)
Esempio n. 3
0
 def GET(self, post_url=None):
     try:
         import hashlib
         post_id = post_url
         post = Post.get_by_id(int(post_id))
         if not post:
             raise web.notfound()
     
         fullpath = web.ctx.home + web.ctx.fullpath
         check = "%s%s" % (fullpath, post.key())
         checksum = hashlib.sha1(check).hexdigest()
     
         comments_query = Comment.all().filter('post =', post)
         if blog.comment_sort == 'asc':
             comments_query.order('created')
         else:
             comments_query.order('-created')
     
         comments = comments_query.fetch(blog.comment_pagesize)
     
         return render('theme/show.html',
                       post=post,
                       checksum=checksum,
                       comments=comments)
     except:
         raise web.notfound()
Esempio n. 4
0
def note_index_post_page():
    """
    添加用户笔记
    """
    editor = g.curr_user
    data = {}
    form = NoteForm()
    data['is_error'] = False
    uid = form.uid.data
    user = None
    if uid:
        user = User.get(uid)
    if not user:
        user = editor

    if form.validate():

        note = add_note(form.title.data, form.content.data, user, editor,
                        x=form.x.data, y=form.y.data, z=form.z.data)

        to_redirect = redirect(url_for('note_page.note_index_page', uid=uid))
        return to_redirect
    else:
        data['is_error'] = True

    data['form'] = form
    notes, pages = get_user_recent_notes(user, limit=60)
    data['notes'] = notes
    data['pages'] = pages
    return render('/note/index.html', **data)
Esempio n. 5
0
def user_register_page():
    """
    用户注册页面
    """
    data = {}
    form = UserRegisterForm()
    data['form'] = form
    return render("/user/register.html", **data)
Esempio n. 6
0
def tool_index_page():
    """
    工具首页
    :return:
    """
    data = {}

    return render("/tool/index.html", **data)
Esempio n. 7
0
 def GET(self):
     try:
         upload_url = blobstore.create_upload_url('/admin/media/upload')
     except:
         upload_url = '/admin/media/upload'
     
     return render('admin/media_upload_blobstore.html',
                   upload_url=upload_url)
Esempio n. 8
0
def user_register_page():
    """
    用户注册页面
    """
    data = {}
    form = UserRegisterForm()
    data['form'] = form
    return render("/user/register.html", **data)
Esempio n. 9
0
def user_login_page():
    """
    用户登录界面
    """
    data = {}
    form = UserLoginForm()

    data['form'] = form
    return render("/user/login.html", **data)
Esempio n. 10
0
 def GET(self, link_id=None):
     link = None
     if link_id:
         link = Link.get_by_id(int(link_id))
         title = u'修改友情链接'
     else:
         title = u'新增友情链接'
     
     return render('admin/link.html',link=link,title=title)
Esempio n. 11
0
def user_login_page():
    """
    用户登录界面
    """
    data = {}
    form = UserLoginForm()

    data['form'] = form
    return render("/user/login.html", **data)
Esempio n. 12
0
 def GET(self, category_id=None):
     category = None
     if category_id:
         category = Category.get_by_id(int(category_id))
         title = u'修改分类'
     else:
         title = u'新增分类'
     
     return render('admin/category.html',category=category,title=title)
Esempio n. 13
0
 def get(self):
     request_url = self.request.path
     if self.request.query_string:
         request_url += '?' + self.request.query_string
     template_values = {
         'request_url': request_url,
     }
     self.response.set_status(404)
     self.response.out.write(template.render('index_404.html', template_values))
Esempio n. 14
0
    def get(self):
        user = users.get_current_user()

        self.lastModified(template.mtime('index.html'))
        self.response.out.write(template.render('index.html',
            presetProxies=((k, v[0]) for k, v in PRESET_PROXIES.items()),
            pacUrlPrefix=PAC_URL_PREFIX,
            pacUserUrlPrefix=PAC_USER_URL_PREFIX,
            userSetting=UserSetting.get_by_key_name(user.user_id()) if user else None,
        ))
Esempio n. 15
0
    def get(self):
        self.lastModified(template.mtime('usage.html'))

        url = self.request.get('u')
        if url: url = 'http://%s/%s%s' % (self.request.host, PAC_URL_PREFIX, url)

        self.response.out.write(template.render('usage.html',
            url=url,
            browser=useragent.family(),
        ))
Esempio n. 16
0
    def get(self):
        self.lastModified(template.mtime('usage.html'))

        url = self.request.get('u')
        if url:
            url = 'http://%s/%s%s' % (self.request.host, PAC_URL_PREFIX, url)

        self.response.out.write(
            template.render(
                'usage.html',
                url=url,
                browser=useragent.family(),
            ))
Esempio n. 17
0
    def get(self):
        user = users.get_current_user()

        self.lastModified(template.mtime('index.html'))
        self.response.out.write(
            template.render(
                'index.html',
                presetProxies=((k, v[0]) for k, v in PRESET_PROXIES.items()),
                pacUrlPrefix=PAC_URL_PREFIX,
                pacUserUrlPrefix=PAC_USER_URL_PREFIX,
                userSetting=UserSetting.get_by_key_name(user.user_id())
                if user else None,
            ))
Esempio n. 18
0
 def GET(self):
     inp = web.input()
     # bookmark = inp.get('bookmark')
     # 
     # query = PagerQuery(Comment).order('-created')
     # prev, comments, next = query.fetch(10, bookmark)
     page = inp.get('page')
     if not page:
         page = 1
     pager = Pager(Comment, 10).order('-created')
     comments = pager.fetch(page)
     
     return render('admin/comments.html',
                   comments=comments,pager=pager)#prev=prev,next=next)
Esempio n. 19
0
    def get(self, name):
        name = name.lower()
        rules = RuleList.getList(name)
        if rules is None:
            self.error(404)
            return

        # Conditional redirect to FeedBurner
        # @see: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464
        if (self.request.get('raw', None) is None
                and  # http://host/path/name.rss?raw
                'FeedBurner'
                not in self.request.user_agent):  # FeedBurner fetcher
            self.redirect('http://feeds.feedburner.com/%s' % name,
                          permanent=False)
            return

        self.lastModified(rules.date)

        start = int(self.request.get('start', 0))
        fetchNum = start + int(self.request.get('num', 20))
        if fetchNum > 1000:
            self.error(412)
            return

        logs = memcache.get('changelog/%s' % name)
        if logs is None or len(logs) < fetchNum:
            diff = ChangeLog.gql("WHERE ruleList = :1 ORDER BY date DESC",
                                 rules).fetch(fetchNum)
            logs = map(generateLogFromDiff, diff)
            memcache.add('changelog/%s' % name, logs)

        self.response.headers['Content-Type'] = Feed.mime_type

        f = Feed(title="%s 更新记录" % name,
                 link=self.request.relative_url(name),
                 description="beta",
                 language="zh")

        for item in logs:
            f.add_item(title="%d月%d日 %s 更新: 增加 %d 条, 删除 %d 条" %
                       (item['timestamp'].month, item['timestamp'].day, name,
                        len(item['block']), len(item['unblock'])),
                       link='',
                       description=template.render('changelogRssItem.html',
                                                   **item),
                       author_name="gfwlist",
                       pubdate=item['timestamp'])

        f.write(self.response.out, 'utf-8')
Esempio n. 20
0
 def GET(self):
     widgets = Widget.all()
     theme = blog.theme
     
     processor = Processor()
     theme = Theme.get_by_key_name(theme)
     sidebar_num = theme.sidebar
     
     # return theme_widget.get('1')
     return render('admin/widget.html',
                   widgets=widgets,
                   sidebar_num=sidebar_num,
                   processor=processor
                  )
Esempio n. 21
0
 def GET(self):
     inp = web.input()
     # bookmark = inp.get('bookmark')
     # 
     # query = PagerQuery(Post).filter('hidden =',False).order('-date')
     # prev, posts, next = query.fetch(blog.post_pagesize, bookmark)
     page = inp.get('page')
     if not page:
         page = 1
     pager = Pager(Post, blog.post_pagesize).order('-date')
     pager.filter('hidden =', False)
     posts = pager.fetch(page)
     
     return render('theme/index.html',posts=posts,pager=pager)#prev=prev,next=next)
Esempio n. 22
0
def render(template_, **param):
    currentUrl = os.getenv('PATH_INFO')
    template_path = os.path.join(settings.TEMPLATE_DIR, template_)
    template_dict = {
        'gfwlist_rss': '/changelog/gfwlist.rss',
        'is_dev': settings.DEBUG,
        'language': 'zh-CN',
        'login_url': users.create_login_url(currentUrl),
        'logout_url': users.create_logout_url(currentUrl),
        'media_url': settings.MEDIA_URL,
        'user': users.get_current_user(),
        'url_protocol': 'https://' if os.getenv('HTTPS') == 'on' else 'http://',
    }
    template_dict.update(param)
    return template.render(template_path, template_dict, debug=settings.TEMPLATE_DEBUG)
Esempio n. 23
0
 def GET(self, post_id=None):
     post = {}
     if post_id:
         # post = Post.get(db.Key.from_path(Post.kind(), int(post_id)))
         post = Post.get_by_id(int(post_id))
         title = u'修改日志'
     else:
         title = u'写新日志'
         post['date'] = datetime.now()
     
     categories = Category.all().order('sort')
     
     return render('admin/post.html',
                   post=post,
                   title=title,
                   categories=categories)
Esempio n. 24
0
 def GET(self):
     inp = web.input()
     page = inp.get('page')
     if not page:
         page = 1
     # offset = (page - 1) * 10
     # bookmark = inp.get('bookmark')
     
     # query = PagerQuery(Post).order('-date')
     # prev, posts, next = query.fetch(10, bookmark)
     # posts = Post.all().order('-date')
     pager = Pager(Post, 10).order('-date')
     posts = pager.fetch(page)
     # posts = Post.all().order('-date').fetch(10, offset)
     # count = Post.all().count()
     
     return render('admin/posts.html',posts=posts,pager=pager)#prev=prev,next=next)
Esempio n. 25
0
def render(template_, **param):
    currentUrl = os.getenv('PATH_INFO')
    template_path = os.path.join(settings.TEMPLATE_DIR, template_)
    template_dict = {
        'gfwlist_rss': '/changelog/gfwlist.rss',
        'is_dev': settings.DEBUG,
        'language': 'zh-CN',
        'login_url': users.create_login_url(currentUrl),
        'logout_url': users.create_logout_url(currentUrl),
        'media_url': settings.MEDIA_URL,
        'user': users.get_current_user(),
        'url_protocol':
        'https://' if os.getenv('HTTPS') == 'on' else 'http://',
    }
    template_dict.update(param)
    return template.render(template_path,
                           template_dict,
                           debug=settings.TEMPLATE_DEBUG)
Esempio n. 26
0
    def get(self, name):
        name = name.lower()
        rules = RuleList.getList(name)
        if rules is None:
            self.error(404)
            return

        # Conditional redirect to FeedBurner
        # @see: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464
        if(self.request.get('raw', None) is None and        # http://host/path/name.rss?raw
           'FeedBurner' not in self.request.user_agent):    # FeedBurner fetcher
            self.redirect('http://feeds.feedburner.com/%s' % name, permanent=False)
            return

        self.lastModified(rules.date)

        start = int(self.request.get('start', 0))
        fetchNum = start + int(self.request.get('num', 20))
        if fetchNum > 1000:
            self.error(412)
            return

        logs = memcache.get('changelog/%s' % name)
        if logs is None or len(logs) < fetchNum:
            diff = ChangeLog.gql("WHERE ruleList = :1 ORDER BY date DESC", rules).fetch(fetchNum)
            logs = map(generateLogFromDiff, diff)
            memcache.add('changelog/%s' % name, logs)

        self.response.headers['Content-Type'] = Feed.mime_type

        f = Feed(title="%s 更新记录" % name,
                 link=self.request.relative_url(name),
                 description="beta",
                 language="zh")

        for item in logs:
            f.add_item(title="%d月%d日 %s 更新: 增加 %d 条, 删除 %d 条" % (item['timestamp'].month, item['timestamp'].day, name, len(item['block']), len(item['unblock'])),
                       link='',
                       description=template.render('changelogRssItem.html', **item),
                       author_name="gfwlist",
                       pubdate=item['timestamp'])

        f.write(self.response.out, 'utf-8')
Esempio n. 27
0
    def get(self):
        greetings = Greeting.all().order('-date')[:5]

        if users.get_current_user():
            current_user = users.get_current_user()
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
        else:
            current_user = ''
            url = users.create_login_url(self.request.uri)
            url_linktext = 'Login'

        template_values = {
            'greetings': greetings,
            'current_user': current_user,
            'url': url,
            'url_linktext': url_linktext,
        }
        self.response.out.write(template.render('guestbook_index.html', template_values))
Esempio n. 28
0
def user_register_post_page():
    """
    用户注册申请
    """
    data = {}
    form = UserRegisterForm()

    if form.validate():
        user = find_email_user(form.email.data)
        if user:
            form.email.errors.append(u'该邮箱已经注册,请输入其他邮箱!')
        else:
            user = add_user(form.email.data, form.password.data)
            to_redirect = redirect(url_for('user_page.user_home_page'))
            response = make_response(to_redirect)
            set_user_login_cookie(user.id, response)
            return response

    data['form'] = form
    return render("/user/register.html", **data)
Esempio n. 29
0
def user_register_post_page():
    """
    用户注册申请
    """
    data = {}
    form = UserRegisterForm()

    if form.validate():
        user = find_email_user(form.email.data)
        if user:
            form.email.errors.append(u'该邮箱已经注册,请输入其他邮箱!')
        else:
            user = add_user(form.email.data, form.password.data)
            to_redirect = redirect(url_for('user_page.user_home_page'))
            response = make_response(to_redirect)
            set_user_login_cookie(user.id, response)
            return response

    data['form'] = form
    return render("/user/register.html", **data)
Esempio n. 30
0
def user_login_post_page():
    """
    用户登录认证
    """
    data = dict()
    form = UserLoginForm()
    if form.validate():
        user = find_email_user(form.email.data)
        if user:
            if user.password == password_encrypt(form.password.data, user.salt):
                to_redirect = redirect(url_for('user_page.user_home_page'))
                response = make_response(to_redirect)
                set_user_login_cookie(user.id, response)
                return response
            else:
                form.password.errors.append(u'密码错误!')
        else:
            form.email.errors.append(u'用户不存在!')

    data['form'] = form
    return render("/user/login.html", **data)
Esempio n. 31
0
def note_index_page():
    """
    用户的笔记
    """
    data = {}
    editor = g.curr_user
    uid = request.args.get('uid', type=int, default=0)

    user = None
    if uid:
        user = User.get(uid)
    if not user:
        user = editor

    form = NoteForm()
    form.uid.data = user.id
    data['form'] = form
    notes, pages = get_user_recent_notes(user, limit=60)
    data['notes'] = notes
    data['pages'] = pages
    return render('/note/index.html', **data)
Esempio n. 32
0
def user_login_post_page():
    """
    用户登录认证
    """
    data = dict()
    form = UserLoginForm()
    if form.validate():
        user = find_email_user(form.email.data)
        if user:
            if user.password == password_encrypt(form.password.data,
                                                 user.salt):
                to_redirect = redirect(url_for('user_page.user_home_page'))
                response = make_response(to_redirect)
                set_user_login_cookie(user.id, response)
                return response
            else:
                form.password.errors.append(u'密码错误!')
        else:
            form.email.errors.append(u'用户不存在!')

    data['form'] = form
    return render("/user/login.html", **data)
Esempio n. 33
0
 def GET(self, category_name):
     if category_name.isdigit():
         category = Category.get_by_id(int(category_name))
     else:
         category = Category.all().filter('alias =', category_name).get()
     
     inp = web.input()
     # bookmark = inp.get('bookmark')
     # 
     # query = PagerQuery(Post).filter('hidden =', False)
     # query.filter('category =', category)
     # query.order('-date')
     # prev, posts, next = query.fetch(blog.post_pagesize, bookmark)
     page = inp.get('page')
     if not page:
         page = 1
     pager = Pager(Post, blog.post_pagesize).order('-date')
     pager.filter('hidden =', False)
     pager.filter('category =', category)
     posts = pager.fetch(page)
     
     return render('theme/index.html',posts=posts,pager=pager)#prev=prev,next=next)
Esempio n. 34
0
def user_work_experience_page():
    """
    用户的工作经历
    """

    data = {}
    user = g.curr_user

    page_form = PageForm()
    form = UserWorkExperienceForm()

    data['page_form'] = page_form
    data['form'] = form

    data['is_error'] = False

    works, pages = find_user_work_experiences(user, limit=page_form.l.data, page=page_form.p.data)
    if not works:
        data['is_error'] = True
    data['works'] = works
    data['pages'] = pages
    return render('/user/work.html', **data)
Esempio n. 35
0
def user_work_experience_page():
    """
    用户的工作经历
    """

    data = {}
    user = g.curr_user

    page_form = PageForm()
    form = UserWorkExperienceForm()

    data['page_form'] = page_form
    data['form'] = form

    data['is_error'] = False

    works, pages = find_user_work_experiences(user,
                                              limit=page_form.l.data,
                                              page=page_form.p.data)
    if not works:
        data['is_error'] = True
    data['works'] = works
    data['pages'] = pages
    return render('/user/work.html', **data)
Esempio n. 36
0
def user_work_experience_post_page():
    """
    用户的工作经历
    """

    data = {}
    user = g.curr_user
    page_form = PageForm()
    form = UserWorkExperienceForm()

    data['page_form'] = page_form
    data['form'] = form

    data['is_error'] = False
    if form.validate():
        #如果提交成功就跳转到get请求上
        #防治用户通过F5刷新重复提交 Post-Redirect-Get (PRG)模式。
        work = add_user_work_experiences(user,
                                         form.company_name.data,
                                         form.position.data,
                                         form.department.data,
                                         form.entry_at.data,
                                         is_resign=form.is_resign.data,
                                         dimission_at=form.dimission_at.data,
                                         company_id=form.company_id.data)
        to_redirect = redirect(url_for('user_page.user_work_experience_page'))
        return to_redirect
    else:
        data['is_error'] = True

    works, pages = find_user_work_experiences(user,
                                              limit=page_form.l.data,
                                              page=page_form.p.data)
    data['works'] = works
    data['pages'] = pages
    return render('/user/work.html', **data)
Esempio n. 37
0
 def GET(self):
     return render('admin/theme_install.html')
Esempio n. 38
0
 def GET(self):
     use_theme = blog.theme
     themes = Theme.all()
     
     return render('admin/theme.html',themes=themes,use_theme=use_theme)
Esempio n. 39
0
 def get(self):
     self.lastModified(template.mtime('gfwtest.html'))
     self.response.out.write(template.render('gfwtest.html'))
Esempio n. 40
0
def company_index_page():
    """
    工作集中营
    """

    return render('/company/index.html')
Esempio n. 41
0
    def GET(self):
        media_list = Media.all().order('-created')

        return render('admin/media_pop.html', media_list=media_list)
Esempio n. 42
0
def user_home_page():
    """
    用户主页
    """
    data = dict(tab=dict(user='******'))
    return render("/user/detail.html", **data)
Esempio n. 43
0
 def get(self):
     self.lastModified(template.mtime('gfwtest.html'))
     self.response.out.write(template.render('gfwtest.html'))