Skip to content

Commit e2cf958

Browse files
committed
Extract LangDev Links base URL as config
1 parent 128895e commit e2cf958

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

logviewer/bot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ def update(bot, m):
5656

5757

5858
def check_link(stream, m):
59+
api_key = current_app.config.get('LANGDEV_LINKS_API_KEY')
60+
if not api_key:
61+
return
5962
nick = m.group('nick')
6063
message = m.group('text')
6164
url_m = URL_REG.match(message)
6265
if url_m:
6366
url = url_m.group(0)
6467
ts = time.time()
6568
auth = hashlib.md5()
66-
auth.update(current_app.config['LANGDEV_LINKS_API_KEY'])
69+
auth.update(api_key)
6770
auth.update(str(int(ts)))
6871
auth.update(hashlib.md5(url).hexdigest())
6972
auth = auth.hexdigest()

logviewer/settings.py.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ SEARCH_RESULTS_PER_PAGE = 100
4848
SECRET_KEY = ''
4949

5050
LANGDEV_LINKS_API_KEY = ''
51+
LANGDEV_LINKS_BASE_URL = '' # 마지막 /를 생략하세요.
5152

5253
FLAG_DB = 'flag.db'

logviewer/templates/log.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-flag"></i> 깃발 <b class="caret"></b></a>
3838
<ul class="dropdown-menu" id="flags"></ul>
3939
</li>
40-
<li><a href="http://links.langdev.org/{{ log.date.strftime('%Y/%m/%d') }}"><i class="glyphicon glyphicon-link"></i> 링크 모아보기</a></li>
40+
{% if config.LANGDEV_LINKS_BASE_URL %}
41+
<li><a href="{{ config.LANGDEV_LINKS_BASE_URL }}/{{ log.date.strftime('%Y/%m/%d') }}"><i class="glyphicon glyphicon-link"></i> 링크 모아보기</a></li>
42+
{% endif %}
4143
</ul>
4244

4345
<form method="get" action="{{ url_for('search') }}" class="navbar-form navbar-right">

0 commit comments

Comments
 (0)