stubbed in ability to use linkpeek as a filter

new file:   liblinkpeek.py
	modified:   pelicanconf.py
	modified:   requirements.txt
This commit is contained in:
russellballestrini 2016-05-23 11:32:05 -04:00
parent 011cb486bf
commit b40cd54238
3 changed files with 36 additions and 0 deletions

21
liblinkpeek.py Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/python
from hashlib import md5
from urllib import quote
# signup for an APIKEY here: https://linkpeek.com/signup
APIKEY = ''
SECRET = ''
def api_v1( uri, apikey=APIKEY, secret=SECRET, size='336' ):
"""LinkPeek.com API v1 helper function"""
token = md5( secret + uri + size ).hexdigest()
uri = quote( uri )
return "http://linkpeek.com/api/v1?uri=%s&apikey=%s&token=%s&size=%s" % (
uri, apikey, token, size)
if __name__ == '__main__':
"""TESTS"""
print api_v1( 'lostquery.com' )
print api_v1( 'http://lostquery.com', size='200x400' )
print api_v1( 'https://lostquery.com', size='400x200' )

View file

@ -11,6 +11,8 @@ DEFAULTS = {
#'THEME' : 'pelican-themes/svbhack',
'THEME' : 'pelican-themes/pelican-svbhack',
'REMARKBOX' : True,
'LINKPEEK_API_KEY' : None,
'LINKPEEK_SECRET_KEY' : None,
}
def get_environ_or_default(key):
@ -24,6 +26,9 @@ THEME = get_environ_or_default('THEME')
REMARKBOX = get_environ_or_default('REMARKBOX')
LINKPEEK_API_KEY = get_environ_or_default('LINKPEEK_API_KEY')
LINKPEEK_SECRET_KEY = get_environ_or_default('LINKPEEK_SECRET_KEY')
# Theme specific
USER_LOGO_URL = 'https://lh3.googleusercontent.com/-uAPZy7NmmP0/AAAAAAAAAAI/AAAAAAAAAnI/iG2P43gCL2U/s125-c/photo.jpg'
TAGLINE = '<a href="/about">Builds Products</a>'
@ -78,3 +83,12 @@ PAGE_SAVE_AS = '{slug}/index.html'
CATEGORY_SAVE_AS = 'category/{slug}/index.html'
TAG_SAVE_AS = 'tags/{slug}/index.html'
AUTHOR_SAVE_AS = 'author/{slug}/index.html'
# needed to add liblinkpeek filter
import ago
import sys
sys.path.append('.')
import liblinkpeek
linkpeek = lambda uri, size : liblinkpeek.api_v1(uri, LINKPEEK_API_KEY, LINKPEEK_SECRET_KEY, size)
JINJA_FILTERS = {'linkpeek':linkpeek, 'ago':ago.human}
# done adding liblinkpeek filter

View file

@ -1 +1,2 @@
pelican
ago