new: dev: url render mode feature
This commit is contained in:
parent
dc455b798f
commit
dcae31e344
@ -45,17 +45,21 @@ Webserver Env config
|
||||
|
||||
Following are available os env config available for bukuserver.
|
||||
|
||||
+-----------------------+--------------------------------+
|
||||
| Name (without prefix) | Value and description |
|
||||
+-----------------------+--------------------------------+
|
||||
| PER_PAGE | v: [`10`]/(positive integer) |
|
||||
| | |
|
||||
| | Bookmark entry per page. |
|
||||
+-----------------------+--------------------------------+
|
||||
| SECRET_KEY | v: [(os.urandom(24))]/(string) |
|
||||
| | |
|
||||
| | Server secret key. |
|
||||
+-----------------------+--------------------------------+
|
||||
+-----------------------+------------------------------------+
|
||||
| Name (without prefix) | Value and description |
|
||||
+-----------------------+------------------------------------+
|
||||
| PER_PAGE | v: [:code:`10`]/(positive integer) |
|
||||
| | |
|
||||
| | Bookmark entry per page. |
|
||||
+-----------------------+------------------------------------+
|
||||
| SECRET_KEY | v: [(os.urandom(24))]/(string) |
|
||||
| | |
|
||||
| | Server secret key. |
|
||||
+-----------------------+------------------------------------+
|
||||
| URL_RENDER_MODE | v: [:code:`full`]/:code:`netloc` |
|
||||
| | |
|
||||
| | Url render mode. |
|
||||
+-----------------------+------------------------------------+
|
||||
|
||||
Note: If any invalid input given, default value will be used
|
||||
|
||||
|
@ -33,6 +33,7 @@ except ImportError:
|
||||
|
||||
|
||||
DEFAULT_PER_PAGE = 10
|
||||
DEFAULT_URL_RENDER_MODE = 'full'
|
||||
STATISTIC_DATA = None
|
||||
|
||||
|
||||
@ -86,6 +87,7 @@ def bookmarks():
|
||||
default=int(
|
||||
current_app.config.get('BUKUSERVER_PER_PAGE', DEFAULT_PER_PAGE))
|
||||
)
|
||||
url_render_mode = current_app.config['BUKUSERVER_URL_RENDER_MODE']
|
||||
create_bookmarks_form = forms.CreateBookmarksForm()
|
||||
if request.method == 'GET':
|
||||
all_bookmarks = bukudb.get_rec_all()
|
||||
@ -131,6 +133,7 @@ def bookmarks():
|
||||
pagination=pagination,
|
||||
search_bookmarks_form=forms.SearchBookmarksForm(),
|
||||
create_bookmarks_form=create_bookmarks_form,
|
||||
url_render_mode=url_render_mode,
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
url_data = create_bookmarks_form.url.data
|
||||
@ -521,6 +524,10 @@ def create_app(config_filename=None):
|
||||
per_page = int(os.getenv('BUKUSERVER_PER_PAGE', DEFAULT_PER_PAGE))
|
||||
per_page = per_page if per_page > 0 else DEFAULT_PER_PAGE
|
||||
app.config['BUKUSERVER_PER_PAGE'] = per_page
|
||||
url_render_mode = os.getenv('BUKUSERVER_URL_RENDER_MODE', DEFAULT_URL_RENDER_MODE)
|
||||
if url_render_mode not in ('full', 'netloc'):
|
||||
url_render_mode = DEFAULT_URL_RENDER_MODE
|
||||
app.config['BUKUSERVER_URL_RENDER_MODE'] = url_render_mode
|
||||
app.config['SECRET_KEY'] = os.getenv('BUKUSERVER_SECRET_KEY') or os.urandom(24)
|
||||
bukudb = BukuDb()
|
||||
app.app_context().push()
|
||||
|
@ -68,7 +68,10 @@
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
|
||||
</a>
|
||||
</h3>
|
||||
{% if url_render_mode == 'netloc' %} ({{item.url|netloc}}) {% endif %}
|
||||
{% if not url_render_mode or url_render_mode == 'full' %}
|
||||
<p><a href="{{item.url}}">{{item.url}}</a></p>
|
||||
{% endif %}
|
||||
<p>{{item.description}}</p>
|
||||
<p>
|
||||
{% for tag in item.tags %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user