mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +01:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4225829e3 | |||
| f3dff354fc | |||
| ca71fa66df | |||
| 09ab5acf76 | |||
| e90d35238a | |||
| 3092f83c8b | |||
| a27787e956 | |||
| 21800911db | |||
| 20a3d9f838 | |||
| 0ab3bd2263 | |||
| 32b074b859 | |||
| 5789bbe006 | |||
| 2ef7358ac7 | |||
| d1e590390c | |||
| 7a1bc11004 | |||
| 315c664fcc | |||
| db5944cec4 | |||
|
|
becb734d17 | ||
| 64ee0856c5 | |||
|
|
6c2be3070e | ||
| 426c2eda68 | |||
| b0e53d4a85 | |||
| 1f69d9e53f | |||
|
|
fc27d9f186 | ||
|
|
6341b384bf | ||
| f698ebfe18 | |||
| 9f736ffe82 | |||
| e1a45a21b5 | |||
| 9492d26511 | |||
| f7762ebc7b | |||
| 1c4bc61494 | |||
| 2a87e0aa1f | |||
| 0a24c7d170 |
@@ -39,6 +39,8 @@ Usage / example configuration
|
||||
Copy ``settings.py`` from example_config to the parent directory and
|
||||
configure to your needs (*at the least* change the value of `SYSTEMKEY`).
|
||||
|
||||
Do not forget to fill in the `MASHAPE_API_KEY` value, which you [can request on the RapidAPI website](https://rapidapi.com/realfavicongenerator/api/realfavicongenerator).
|
||||
|
||||
Run digimarks as a service under nginx or apache and call the appropriate
|
||||
url's when wanted.
|
||||
|
||||
|
||||
48
digimarks.py
48
digimarks.py
@@ -10,10 +10,11 @@ import sys
|
||||
|
||||
import bs4
|
||||
import requests
|
||||
from flask import (Flask, abort, jsonify, redirect, render_template, request,
|
||||
url_for)
|
||||
from dateutil import tz
|
||||
from feedgen.feed import FeedGenerator
|
||||
from flask import (Flask, abort, jsonify, make_response, redirect,
|
||||
render_template, request, url_for)
|
||||
from peewee import * # noqa
|
||||
from werkzeug.contrib.atom import AtomFeed
|
||||
|
||||
try:
|
||||
# Python 3
|
||||
@@ -357,14 +358,14 @@ class Bookmark(BaseModel):
|
||||
def _set_favicon_with_realfavicongenerator(self, domain):
|
||||
""" Fetch favicon for the domain """
|
||||
response = requests.get(
|
||||
'https://realfavicongenerator.p.mashape.com/favicon/icon?platform=android_chrome&site=' + domain,
|
||||
'https://realfavicongenerator.p.rapidapi.com/favicon/icon?platform=android_chrome&site=' + domain,
|
||||
stream=True,
|
||||
headers={'User-Agent': DIGIMARKS_USER_AGENT, 'X-Mashape-Key': settings.MASHAPE_API_KEY}
|
||||
)
|
||||
if response.status_code == 404:
|
||||
# Fall back to desktop favicon
|
||||
response = requests.get(
|
||||
'https://realfavicongenerator.p.mashape.com/favicon/icon?platform=desktop&site=' + domain,
|
||||
'https://realfavicongenerator.p.rapidapi.com/favicon/icon?platform=desktop&site=' + domain,
|
||||
stream=True,
|
||||
headers={'User-Agent': DIGIMARKS_USER_AGENT, 'X-Mashape-Key': settings.MASHAPE_API_KEY}
|
||||
)
|
||||
@@ -604,10 +605,12 @@ def bookmarks_js(userkey):
|
||||
Bookmark.userkey == userkey,
|
||||
Bookmark.status == Bookmark.VISIBLE
|
||||
).order_by(Bookmark.created_date.desc())
|
||||
return render_template(
|
||||
resp = make_response(render_template(
|
||||
'bookmarks.js',
|
||||
bookmarks=bookmarks
|
||||
)
|
||||
))
|
||||
resp.headers['Content-type'] = 'text/javascript; charset=utf-8'
|
||||
return resp
|
||||
|
||||
|
||||
@app.route('/r/<userkey>/<urlhash>')
|
||||
@@ -960,23 +963,34 @@ def publictag_feed(tagkey):
|
||||
Bookmark.tags.contains(this_tag.tag),
|
||||
Bookmark.status == Bookmark.VISIBLE
|
||||
)
|
||||
feed = AtomFeed(this_tag.tag, feed_url=request.url, url=make_external(url_for('publictag_page', tagkey=tagkey)))
|
||||
|
||||
feed = FeedGenerator()
|
||||
feed.title(this_tag.tag)
|
||||
feed.id(request.url)
|
||||
feed.link(href=request.url, rel='self')
|
||||
feed.link(href=make_external(url_for('publictag_page', tagkey=tagkey)))
|
||||
|
||||
for bookmark in bookmarks:
|
||||
entry = feed.add_entry()
|
||||
|
||||
updated_date = bookmark.modified_date
|
||||
if not bookmark.modified_date:
|
||||
updated_date = bookmark.created_date
|
||||
bookmarktitle = '{} (no title)'.format(bookmark.url)
|
||||
if bookmark.title:
|
||||
bookmarktitle = bookmark.title
|
||||
feed.add(
|
||||
bookmarktitle,
|
||||
content_type='html',
|
||||
author='digimarks',
|
||||
url=bookmark.url,
|
||||
updated=updated_date,
|
||||
published=bookmark.created_date
|
||||
)
|
||||
return feed.get_response()
|
||||
|
||||
entry.id(bookmark.url)
|
||||
entry.title(bookmarktitle)
|
||||
entry.link(href=bookmark.url)
|
||||
entry.author(name='digimarks')
|
||||
entry.pubdate(bookmark.created_date.replace(tzinfo=tz.tzlocal()))
|
||||
entry.published(bookmark.created_date.replace(tzinfo=tz.tzlocal()))
|
||||
entry.updated(updated_date.replace(tzinfo=tz.tzlocal()))
|
||||
|
||||
response = make_response(feed.atom_str(pretty=True))
|
||||
response.headers.set('Content-Type', 'application/atom+xml')
|
||||
return response
|
||||
except PublicTag.DoesNotExist:
|
||||
abort(404)
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ DEBUG = False
|
||||
# echo -n "yourstring" | sha1sum
|
||||
SYSTEMKEY = 'S3kr1t'
|
||||
|
||||
# RapidAPI key for favicons
|
||||
# https://rapidapi.com/realfavicongenerator/api/realfavicongenerator
|
||||
MASHAPE_API_KEY = 'your_MASHAPE_key'
|
||||
|
||||
LOG_LOCATION = 'digimarks.log'
|
||||
#LOG_LOCATION = '/var/log/digimarks/digimarks.log'
|
||||
# How many logs to keep in log rotation:
|
||||
|
||||
@@ -1,28 +1,70 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
# This file is autogenerated by pip-compile with Python 3.10
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --output-file requirements-dev.txt requirements-dev.in
|
||||
# pip-compile requirements-dev.in
|
||||
#
|
||||
astroid==2.0.4 # via pylint
|
||||
beautifulsoup4==4.6.3 # via bs4
|
||||
astroid==2.15.6
|
||||
# via pylint
|
||||
beautifulsoup4==4.12.2
|
||||
# via bs4
|
||||
blinker==1.6.2
|
||||
# via flask
|
||||
bs4==0.0.1
|
||||
certifi==2018.8.24 # via requests
|
||||
chardet==3.0.4 # via requests
|
||||
click==6.7 # via flask
|
||||
flask==1.0.2
|
||||
idna==2.7 # via requests
|
||||
isort==4.3.4 # via pylint
|
||||
itsdangerous==0.24 # via flask
|
||||
jinja2==2.10 # via flask
|
||||
lazy-object-proxy==1.3.1 # via astroid
|
||||
markupsafe==1.0 # via jinja2
|
||||
mccabe==0.6.1 # via pylint
|
||||
peewee==3.7.0
|
||||
pylint==2.1.1
|
||||
requests==2.19.1
|
||||
six==1.11.0 # via astroid
|
||||
typed-ast==1.1.0 # via astroid
|
||||
urllib3==1.23 # via requests
|
||||
werkzeug==0.14.1 # via flask
|
||||
wrapt==1.10.11 # via astroid
|
||||
# via -r requirements.in
|
||||
certifi==2023.7.22
|
||||
# via requests
|
||||
charset-normalizer==3.2.0
|
||||
# via requests
|
||||
click==8.1.6
|
||||
# via flask
|
||||
dill==0.3.7
|
||||
# via pylint
|
||||
feedgen==0.9.0
|
||||
# via -r requirements.in
|
||||
flask==2.3.2
|
||||
# via -r requirements.in
|
||||
idna==3.4
|
||||
# via requests
|
||||
isort==5.12.0
|
||||
# via pylint
|
||||
itsdangerous==2.1.2
|
||||
# via flask
|
||||
jinja2==3.1.2
|
||||
# via flask
|
||||
lazy-object-proxy==1.9.0
|
||||
# via astroid
|
||||
lxml==4.9.3
|
||||
# via feedgen
|
||||
markupsafe==2.1.3
|
||||
# via
|
||||
# jinja2
|
||||
# werkzeug
|
||||
mccabe==0.7.0
|
||||
# via pylint
|
||||
peewee==3.16.2
|
||||
# via -r requirements.in
|
||||
platformdirs==3.9.1
|
||||
# via pylint
|
||||
pylint==2.17.5
|
||||
# via -r requirements-dev.in
|
||||
python-dateutil==2.8.2
|
||||
# via feedgen
|
||||
requests==2.31.0
|
||||
# via -r requirements.in
|
||||
six==1.16.0
|
||||
# via python-dateutil
|
||||
soupsieve==2.4.1
|
||||
# via beautifulsoup4
|
||||
tomli==2.0.1
|
||||
# via pylint
|
||||
tomlkit==0.11.8
|
||||
# via pylint
|
||||
typing-extensions==4.7.1
|
||||
# via astroid
|
||||
urllib3==2.0.4
|
||||
# via requests
|
||||
werkzeug==2.3.6
|
||||
# via flask
|
||||
wrapt==1.15.0
|
||||
# via astroid
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
# Core application
|
||||
flask
|
||||
peewee
|
||||
|
||||
# Fetch title etc from links
|
||||
bs4
|
||||
requests
|
||||
|
||||
# Generate (atom) feeds for tags and such
|
||||
feedgen
|
||||
|
||||
@@ -1,20 +1,48 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile
|
||||
# To update, run:
|
||||
# This file is autogenerated by pip-compile with Python 3.10
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --output-file requirements.txt requirements.in
|
||||
# pip-compile requirements.in
|
||||
#
|
||||
beautifulsoup4==4.6.3 # via bs4
|
||||
beautifulsoup4==4.12.2
|
||||
# via bs4
|
||||
blinker==1.6.2
|
||||
# via flask
|
||||
bs4==0.0.1
|
||||
certifi==2018.8.24 # via requests
|
||||
chardet==3.0.4 # via requests
|
||||
click==6.7 # via flask
|
||||
flask==1.0.2
|
||||
idna==2.7 # via requests
|
||||
itsdangerous==0.24 # via flask
|
||||
jinja2==2.10 # via flask
|
||||
markupsafe==1.0 # via jinja2
|
||||
peewee==3.7.0
|
||||
requests==2.19.1
|
||||
urllib3==1.23 # via requests
|
||||
werkzeug==0.14.1 # via flask
|
||||
# via -r requirements.in
|
||||
certifi==2023.7.22
|
||||
# via requests
|
||||
charset-normalizer==3.2.0
|
||||
# via requests
|
||||
click==8.1.6
|
||||
# via flask
|
||||
feedgen==0.9.0
|
||||
# via -r requirements.in
|
||||
flask==2.3.2
|
||||
# via -r requirements.in
|
||||
idna==3.4
|
||||
# via requests
|
||||
itsdangerous==2.1.2
|
||||
# via flask
|
||||
jinja2==3.1.2
|
||||
# via flask
|
||||
lxml==4.9.3
|
||||
# via feedgen
|
||||
markupsafe==2.1.3
|
||||
# via
|
||||
# jinja2
|
||||
# werkzeug
|
||||
peewee==3.16.2
|
||||
# via -r requirements.in
|
||||
python-dateutil==2.8.2
|
||||
# via feedgen
|
||||
requests==2.31.0
|
||||
# via -r requirements.in
|
||||
six==1.16.0
|
||||
# via python-dateutil
|
||||
soupsieve==2.4.1
|
||||
# via beautifulsoup4
|
||||
urllib3==2.0.4
|
||||
# via requests
|
||||
werkzeug==2.3.6
|
||||
# via flask
|
||||
|
||||
Reference in New Issue
Block a user