Skip to content

Commit 38b27a2

Browse files
committed
py3
1 parent 8a95acd commit 38b27a2

7 files changed

Lines changed: 1109 additions & 1043 deletions

File tree

app/OctBlog/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from flask_login import LoginManager
99
from flask_principal import Principal
1010

11-
from config import config
11+
from .config import config
1212

1313
db = MongoEngine()
1414

app/OctBlog/config.py

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
3+
from __future__ import unicode_literals
44
import os, sys, datetime
55

66
OctBlogSettings = {
@@ -10,13 +10,13 @@
1010
'allow_donate': os.environ.get('allow_donate', 'true').lower() == 'true',
1111
'auto_role': os.environ.get('auto_role', 'reader').lower(),
1212
'blog_meta': {
13-
'name': os.environ.get('name').decode('utf8') if os.environ.get('name') else 'Oct Blog',
14-
'subtitle': os.environ.get('subtitle').decode('utf8') if os.environ.get('subtitle') else 'Oct Blog Subtitle',
15-
'description': os.environ.get('description').decode('utf8') if os.environ.get('description') else 'Oct Blog Description',
16-
'wechat_name': os.environ.get('wechat_name').decode('utf8') if os.environ.get('wechat_name') else 'Oct Blog Wechat Root',
17-
'wechat_subtitle': os.environ.get('wechat_subtitle').decode('utf8') if os.environ.get('wechat_subtitle') else 'Oct Blog Wechat Subtitle',
18-
'owner': os.environ.get('owner').decode('utf8') if os.environ.get('owner') else 'Gevin',
19-
'keywords': os.environ.get('keywords').decode('utf8') if os.environ.get('keywords') else 'python,django,flask,docker,MongoDB',
13+
'name': os.environ.get('name') if os.environ.get('name') else 'Oct Blog',
14+
'subtitle': os.environ.get('subtitle') if os.environ.get('subtitle') else 'Oct Blog Subtitle',
15+
'description': os.environ.get('description') if os.environ.get('description') else 'Oct Blog Description',
16+
'wechat_name': os.environ.get('wechat_name') if os.environ.get('wechat_name') else 'Oct Blog Wechat Root',
17+
'wechat_subtitle': os.environ.get('wechat_subtitle') if os.environ.get('wechat_subtitle') else 'Oct Blog Wechat Subtitle',
18+
'owner': os.environ.get('owner') if os.environ.get('owner') else 'Gevin',
19+
'keywords': os.environ.get('keywords') if os.environ.get('keywords') else 'python,django,flask,docker,MongoDB',
2020
'google_site_verification': os.environ.get('google_site_verification') or '12345678',
2121
'baidu_site_verification': os.environ.get('baidu_site_verification') or '87654321',
2222
'sogou_site_verification': os.environ.get('sogou_site_verification') or '87654321',
@@ -39,15 +39,15 @@
3939
},
4040
'donation': {
4141
'allow_donate': os.environ.get('allow_donate', 'true').lower() == 'true',
42-
'donation_msg': os.environ.get('donation_msg', 'You can donate to me if the article makes sense to you').decode('utf8')
42+
'donation_msg': os.environ.get('donation_msg', 'You can donate to me if the article makes sense to you')
4343
},
4444
'wechat': {
4545
'display_wechat': os.environ.get('display_wechat', 'true').lower() == 'true',
46-
'wechat_msg': os.environ.get('wechat_msg', 'Welcome to follow my wechat').decode('utf8')
46+
'wechat_msg': os.environ.get('wechat_msg', 'Welcome to follow my wechat')
4747
},
4848
'copyright': {
4949
'display_copyright': os.environ.get('allow_display_copyright', 'true').lower() == 'true',
50-
'copyright_msg': os.environ.get('copyright_msg', 'The article is not allowed to repost unless author authorized').decode('utf8')
50+
'copyright_msg': os.environ.get('copyright_msg', 'The article is not allowed to repost unless author authorized')
5151
},
5252
'only_abstract_in_feed': os.environ.get('only_abstract_in_feed', 'false').lower() == 'true',
5353
'allow_share_article': os.environ.get('allow_share_article', 'true').lower() == 'true',
@@ -61,6 +61,65 @@
6161

6262
}
6363

64+
# OctBlogSettings = {
65+
# 'post_types': ('post', 'page'), # deprecated
66+
# 'allow_registration': os.environ.get('allow_registration', 'false').lower() == 'true',
67+
# 'allow_su_creation': os.environ.get('allow_su_creation', 'false').lower() == 'true',
68+
# 'allow_donate': os.environ.get('allow_donate', 'true').lower() == 'true',
69+
# 'auto_role': os.environ.get('auto_role', 'reader').lower(),
70+
# 'blog_meta': {
71+
# # 'name': os.environ.get('name').decode('utf8') if os.environ.get('name') else 'Oct Blog',
72+
# 'name': os.environ.get('name') if os.environ.get('name') else 'Oct Blog',
73+
# 'subtitle': os.environ.get('subtitle').decode('utf8') if os.environ.get('subtitle') else 'Oct Blog Subtitle',
74+
# 'description': os.environ.get('description').decode('utf8') if os.environ.get('description') else 'Oct Blog Description',
75+
# 'wechat_name': os.environ.get('wechat_name').decode('utf8') if os.environ.get('wechat_name') else 'Oct Blog Wechat Root',
76+
# 'wechat_subtitle': os.environ.get('wechat_subtitle').decode('utf8') if os.environ.get('wechat_subtitle') else 'Oct Blog Wechat Subtitle',
77+
# 'owner': os.environ.get('owner').decode('utf8') if os.environ.get('owner') else 'Gevin',
78+
# 'keywords': os.environ.get('keywords').decode('utf8') if os.environ.get('keywords') else 'python,django,flask,docker,MongoDB',
79+
# 'google_site_verification': os.environ.get('google_site_verification') or '12345678',
80+
# 'baidu_site_verification': os.environ.get('baidu_site_verification') or '87654321',
81+
# 'sogou_site_verification': os.environ.get('sogou_site_verification') or '87654321',
82+
# },
83+
# 'search_engine_submit_urls':{
84+
# 'baidu': os.environ.get('baidu_submit_url')
85+
# },
86+
# 'pagination':{
87+
# 'per_page': int(os.environ.get('per_page', 5)),
88+
# 'admin_per_page': int(os.environ.get('admin_per_page', 10)),
89+
# 'archive_per_page': int(os.environ.get('admin_per_page', 20)),
90+
# },
91+
# 'blog_comment':{
92+
# 'allow_comment': os.environ.get('allow_comment', 'true').lower() == 'true',
93+
# 'comment_type': os.environ.get('comment_type', 'octblog').lower(), # currently, OctBlog only supports duoshuo comment
94+
# 'comment_opt':{
95+
# 'octblog': 'oct-blog', # shotname of octblog
96+
# 'duoshuo': 'oct-blog', # shotname of duoshuo
97+
# }
98+
# },
99+
# 'donation': {
100+
# 'allow_donate': os.environ.get('allow_donate', 'true').lower() == 'true',
101+
# 'donation_msg': os.environ.get('donation_msg', 'You can donate to me if the article makes sense to you').decode('utf8')
102+
# },
103+
# 'wechat': {
104+
# 'display_wechat': os.environ.get('display_wechat', 'true').lower() == 'true',
105+
# 'wechat_msg': os.environ.get('wechat_msg', 'Welcome to follow my wechat').decode('utf8')
106+
# },
107+
# 'copyright': {
108+
# 'display_copyright': os.environ.get('allow_display_copyright', 'true').lower() == 'true',
109+
# 'copyright_msg': os.environ.get('copyright_msg', 'The article is not allowed to repost unless author authorized').decode('utf8')
110+
# },
111+
# 'only_abstract_in_feed': os.environ.get('only_abstract_in_feed', 'false').lower() == 'true',
112+
# 'allow_share_article': os.environ.get('allow_share_article', 'true').lower() == 'true',
113+
# 'gavatar_cdn_base': os.environ.get('gavatar_cdn_base', '//cdn.v2ex.com/gravatar/'),
114+
# 'gavatar_default_image': os.environ.get('gavatar_default_image', 'http://7tsygu.com1.z0.glb.clouddn.com/user-avatar.jpg'),
115+
# 'background_image': {
116+
# 'home': os.environ.get('bg_home') or 'http://7d9q7a.com1.z0.glb.clouddn.com/octblog-bg.jpg',
117+
# 'post': os.environ.get('bg_post') or 'http://7d9q7a.com1.z0.glb.clouddn.com/octblog-bg.jpg',
118+
# 'about': os.environ.get('bg_about') or 'http://7d9q7a.com1.z0.glb.clouddn.com/octblog_about.jpg'
119+
# },
120+
121+
# }
122+
64123
class Config(object):
65124
DEBUG = False
66125
TESTING = False

app/accounts/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
import datetime
23
# from flask.ext.login import UserMixin
34
from flask_login import UserMixin
@@ -46,7 +47,9 @@ def verify_password(self, password):
4647

4748
def get_id(self):
4849
try:
49-
return unicode(self.username)
50+
# return unicode(self.username)
51+
return self.username
52+
5053
except AttributeError:
5154
raise NotImplementedError('No `username` attribute - override `get_id`')
5255

app/accounts/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from flask_principal import Identity, AnonymousIdentity, identity_changed
1111

1212
from . import models, forms
13-
from permissions import admin_permission, su_permission
13+
from .permissions import admin_permission, su_permission
1414
from OctBlog.config import OctBlogSettings
1515

1616
def login():

0 commit comments

Comments
 (0)