commit
07c2a6d189
@ -1,3 +1,12 @@
|
||||
Buku v3.X
|
||||
Unreleased
|
||||
|
||||
What's in?
|
||||
- Several dependencies is now required on installation
|
||||
- Bukuserver will use Flask-Admin
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Buku v3.8
|
||||
2018-05-24
|
||||
|
||||
|
@ -71,36 +71,42 @@ ENV BUKUSERVER_PER_PAGE=100
|
||||
|
||||
<p><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/EELmkRU.png"><img src="https://i.imgur.com/EELmkRU.png" alt="home page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/LozEqsT.png"><img src="https://i.imgur.com/LozEqsT.png" alt="home page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>home page</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/MBgdf6L.png"><img src="https://i.imgur.com/MBgdf6L.png" alt="index page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/DJUzs1d.png"><img src="https://i.imgur.com/DJUzs1d.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>bookmark stats</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/tnRWsds.png"><img src="https://i.imgur.com/tnRWsds.png" alt="index page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/1eMruZD.png"><img src="https://i.imgur.com/1eMruZD.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>bookmark page (1)</i></a></p>
|
||||
<p align="center"><i>bookmark page</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/W5onldC.png"><img src="https://i.imgur.com/W5onldC.png" alt="index page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/W4VUKQV.png"><img src="https://i.imgur.com/W4VUKQV.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>bookmark page (2)</i></a></p>
|
||||
<p align="center"><i>create bookmark</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/ONW70gy.png"><img src="https://i.imgur.com/ONW70gy.png" alt="index page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/213y0Ft.png"><img src="https://i.imgur.com/213y0Ft.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>bookmark edit page</i></a></p>
|
||||
<p align="center"><i>edit bookmark</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/ohctZyu.png"><img src="https://i.imgur.com/ohctZyu.png" alt="index page" width="650"/></a>
|
||||
<a href="https://i.imgur.com/MQM07VZ.png"><img src="https://i.imgur.com/MQM07VZ.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>view bookmark details</i></a></p>
|
||||
|
||||
<p><br><br></p>
|
||||
<p align="center">
|
||||
<a href="https://i.imgur.com/0bYgpER.png"><img src="https://i.imgur.com/0bYgpER.png" alt="index page" width="650"/></a>
|
||||
</p>
|
||||
<p align="center"><i>tag page</i></a></p>
|
||||
|
@ -3,7 +3,6 @@
|
||||
"""Server module."""
|
||||
import os
|
||||
import sys
|
||||
from collections import Counter
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from buku import BukuDb, __version__, network_handler
|
||||
@ -13,7 +12,6 @@ from flask_api import exceptions, FlaskAPI, status
|
||||
from flask_bootstrap import Bootstrap
|
||||
from flask_paginate import Pagination, get_page_parameter, get_per_page_parameter
|
||||
from markupsafe import Markup
|
||||
import arrow
|
||||
import click
|
||||
import flask
|
||||
from flask import (
|
||||
@ -466,93 +464,6 @@ def search_bookmarks():
|
||||
return res
|
||||
|
||||
|
||||
def view_statistic():
|
||||
bukudb = getattr(flask.g, 'bukudb', BukuDb())
|
||||
global STATISTIC_DATA
|
||||
statistic_data = STATISTIC_DATA
|
||||
if not statistic_data or request.method == 'POST':
|
||||
all_bookmarks = bukudb.get_rec_all()
|
||||
netloc = [urlparse(x[1]).netloc for x in all_bookmarks]
|
||||
tag_set = [x[3] for x in all_bookmarks]
|
||||
tag_items = []
|
||||
for tags in tag_set:
|
||||
tag_items.extend([x.strip() for x in tags.split(',') if x.strip()])
|
||||
tag_counter = Counter(tag_items)
|
||||
title_items = [x[2] for x in all_bookmarks]
|
||||
title_counter = Counter(title_items)
|
||||
statistic_datetime = arrow.now()
|
||||
STATISTIC_DATA = {
|
||||
'datetime': statistic_datetime,
|
||||
'netloc': netloc,
|
||||
'tag_counter': tag_counter,
|
||||
'title_counter': title_counter,
|
||||
}
|
||||
else:
|
||||
netloc = statistic_data['netloc']
|
||||
statistic_datetime = statistic_data['datetime']
|
||||
tag_counter = statistic_data['tag_counter']
|
||||
title_counter = statistic_data['title_counter']
|
||||
|
||||
netloc_counter = Counter(netloc)
|
||||
unique_netloc_len = len(set(netloc))
|
||||
colors = [
|
||||
"#F7464A", "#46BFBD", "#FDB45C", "#FEDCBA",
|
||||
"#ABCDEF", "#DDDDDD", "#ABCABC", "#4169E1",
|
||||
"#C71585", "#FF4500", "#FEDCBA", "#46BFBD"]
|
||||
show_netloc_table = False
|
||||
if unique_netloc_len > len(colors):
|
||||
max_netloc_item = len(colors)
|
||||
netloc_colors = colors
|
||||
show_netloc_table = True
|
||||
else:
|
||||
netloc_colors = colors[:unique_netloc_len]
|
||||
max_netloc_item = unique_netloc_len
|
||||
most_common_netlocs = netloc_counter.most_common(max_netloc_item)
|
||||
most_common_netlocs = [
|
||||
[val[0], val[1], netloc_colors[idx]] for idx, val in enumerate(most_common_netlocs)]
|
||||
|
||||
unique_tag_len = len(tag_counter)
|
||||
show_tag_rank_table = False
|
||||
if unique_tag_len > len(colors):
|
||||
max_tag_item = len(colors)
|
||||
tag_colors = colors
|
||||
show_tag_rank_table = True
|
||||
else:
|
||||
tag_colors = colors[:unique_tag_len]
|
||||
max_tag_item = unique_tag_len
|
||||
most_common_tags = tag_counter.most_common(max_tag_item)
|
||||
most_common_tags = [
|
||||
[val[0], val[1], tag_colors[idx]] for idx, val in enumerate(most_common_tags)]
|
||||
|
||||
unique_title_len = len(title_counter)
|
||||
show_title_rank_table = False
|
||||
if unique_title_len > len(colors):
|
||||
max_title_item = len(colors)
|
||||
title_colors = colors
|
||||
show_title_rank_table = True
|
||||
else:
|
||||
title_colors = colors[:unique_title_len]
|
||||
max_title_item = unique_title_len
|
||||
most_common_titles = title_counter.most_common(max_title_item)
|
||||
most_common_titles = [
|
||||
[val[0], val[1], title_colors[idx]] for idx, val in enumerate(most_common_titles)]
|
||||
|
||||
return render_template(
|
||||
'bukuserver/statistic.html',
|
||||
most_common_netlocs=most_common_netlocs,
|
||||
netloc_counter=netloc_counter,
|
||||
show_netloc_table=show_netloc_table,
|
||||
most_common_tags=most_common_tags,
|
||||
tag_counter=tag_counter,
|
||||
show_tag_rank_table=show_tag_rank_table,
|
||||
most_common_titles=most_common_titles,
|
||||
title_counter=title_counter,
|
||||
show_title_rank_table=show_title_rank_table,
|
||||
datetime=statistic_datetime,
|
||||
datetime_text=statistic_datetime.humanize(arrow.now(), granularity='second'),
|
||||
)
|
||||
|
||||
|
||||
def create_app(config_filename=None):
|
||||
"""create app."""
|
||||
app = FlaskAPI(__name__)
|
||||
|
@ -81,10 +81,11 @@ class BookmarkModelView(BaseModelView):
|
||||
netloc, scheme = parsed_url.netloc, parsed_url.scheme
|
||||
is_scheme_valid = scheme in ('http', 'https')
|
||||
tag_text = []
|
||||
tag_tmpl = '<a class="btn btn-default" href="#">{0}</a>'
|
||||
tag_tmpl = '<a class="btn btn-default" href="{1}">{0}</a>'
|
||||
for tag in model.tags.split(','):
|
||||
if tag:
|
||||
tag_text.append(tag_tmpl.format(tag))
|
||||
tag_text.append(tag_tmpl.format(tag, url_for(
|
||||
'bookmark.index_view', flt2_tags_contain=tag)))
|
||||
if not netloc:
|
||||
return Markup("""\
|
||||
{0.title}<br/>{2}<br/>{1}{0.description}
|
||||
@ -100,13 +101,21 @@ class BookmarkModelView(BaseModelView):
|
||||
else:
|
||||
res += title
|
||||
if self.url_render_mode == 'netloc':
|
||||
res += ' ({})'.format(netloc)
|
||||
res += ' (<a href="{1}">{0}</a>)'.format(
|
||||
netloc,
|
||||
url_for('bookmark.index_view', flt2_url_netloc_match=netloc)
|
||||
)
|
||||
res += '<br/>'
|
||||
if not is_scheme_valid:
|
||||
res += model.url
|
||||
elif self.url_render_mode is None or self.url_render_mode == 'full':
|
||||
res += '<a href="{0.url}">{0.url}</a>'.format(model)
|
||||
res += '<br/>'
|
||||
if self.url_render_mode != 'netloc':
|
||||
res += tag_tmpl.format(
|
||||
'netloc:{}'.format(netloc),
|
||||
url_for('bookmark.index_view', flt2_url_netloc_match=netloc)
|
||||
)
|
||||
res += ''.join(tag_text)
|
||||
description = model.description
|
||||
if description:
|
||||
@ -469,7 +478,7 @@ class TagModelView(BaseModelView):
|
||||
|
||||
class StatisticView(BaseView): # pylint: disable=too-few-public-methods
|
||||
|
||||
@expose('/')
|
||||
@expose('/', methods=('GET', 'POST'))
|
||||
def index(self):
|
||||
bukudb = BukuDb()
|
||||
global STATISTIC_DATA
|
||||
|
Loading…
x
Reference in New Issue
Block a user