Skip to content

Commit

Permalink
Merge pull request #264 from liangliangyy/dev
Browse files Browse the repository at this point in the history
Fix #260 Fix #262
  • Loading branch information
liangliangyy committed May 11, 2019
2 parents c3e9696 + 8c97d40 commit bf81330
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions DjangoBlog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,23 @@ def news(*args, **kwargs):
key = view.get_cache_key()
except:
key = None
pass
if not key:
unique_str = repr((func, args, kwargs))

m = md5(unique_str.encode('utf-8'))
key = m.hexdigest()
value = cache.get(key)
if value:
if value is not None:
# logger.info('cache_decorator get cache:%s key:%s' % (func.__name__, key))
if repr(value) == 'default':
if str(value) == '__default_cache_value__':
return None
else:
return value
else:
logger.info('cache_decorator set cache:%s key:%s' % (func.__name__, key))
value = func(*args, **kwargs)
if not value:
cache.set(key, 'default', expiration)
if value is None:
cache.set(key, '__default_cache_value__', expiration)
else:
cache.set(key, value, expiration)
return value
Expand Down
6 changes: 4 additions & 2 deletions bin/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ CACHES = {

现在已经支持微博,Google,GitHub,Facebook登录,需要在其对应的开放平台申请oauth登录权限,然后在
**后台->Oauth** 配置中新增配置,填写对应的`appkey``appsecret`以及回调地址。


### 回调地址示例:
qq:http://你的域名/oauth/authorize?type=qq
微博:http://你的域名/oauth/authorize?type=weibo
type对应在`oauthmanager`中的type字段。

## owntracks:
owntracks是一个位置追踪软件,可以定时的将你的坐标提交到你的服务器上,现在简单的支持owntracks功能,需要安装owntracks的app,然后将api地址设置为:
Expand Down
2 changes: 1 addition & 1 deletion blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def load_sidebar(user, linktype):
tags = Tag.objects.all()
sidebar_tags = None
if tags and len(tags) > 0:
s = [t for t in [(t, t.get_article_count()) for t in tags] if t[1] > 0]
s = [t for t in [(t, t.get_article_count()) for t in tags] if t[1]]
count = sum([t[1] for t in s])
dd = 1 if (count == 0 or not len(tags)) else count / len(tags)
import random
Expand Down

0 comments on commit bf81330

Please sign in to comment.