Browse Source

Initial PWA work because i'm insane

mistress
Daniel Muckerman 4 years ago
parent
commit
1859bfff28
11 changed files with 152 additions and 4 deletions
  1. +16
    -1
      app.py
  2. +20
    -0
      manifest.json
  3. BIN
      pocket/readitlater.db
  4. +4
    -0
      static/add_modal.js
  5. BIN
      static/read-it-later.png
  6. +68
    -1
      static/style.css
  7. +10
    -1
      templates/article.j2
  8. +9
    -0
      templates/bookmarklet.j2
  9. +3
    -0
      templates/fragments/navbar.j2
  10. +10
    -0
      templates/list.j2
  11. +12
    -1
      templates/login.j2

+ 16
- 1
app.py View File

@ -1,13 +1,15 @@
from utils import clean_articles from utils import clean_articles
import ldap as l import ldap as l
from ldap3 import Server, Connection, ALL, MODIFY_REPLACE from ldap3 import Server, Connection, ALL, MODIFY_REPLACE
from flask import Flask, g, request, session, redirect, url_for, render_template
from flask import Flask, g, request, session, redirect, url_for, render_template, send_from_directory
from flask_simpleldap import LDAP from flask_simpleldap import LDAP
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
import os import os
import sqlite3 import sqlite3
import requests import requests
from utils import clean_articles, get_article from utils import clean_articles, get_article
from flask_cache_buster import CacheBuster
app = Flask(__name__) app = Flask(__name__)
Bootstrap(app) Bootstrap(app)
@ -30,6 +32,14 @@ short_domain = os.environ.get('SHORT_DOMAIN')
ldap = LDAP(app) ldap = LDAP(app)
config = {
'extensions': ['.js', '.css', '.csv'],
'hash_size': 10
}
cache_buster = CacheBuster(config=config)
cache_buster.register_cache_buster(app)
server = Server(app.config['LDAP_HOST']) server = Server(app.config['LDAP_HOST'])
conn = Connection(server, app.config['LDAP_USERNAME'], app.config['LDAP_PASSWORD'], auto_bind=True) conn = Connection(server, app.config['LDAP_USERNAME'], app.config['LDAP_PASSWORD'], auto_bind=True)
@ -41,6 +51,11 @@ def before_request():
g.user = {} g.user = {}
@app.route("/manifest.json")
def manifest():
return send_from_directory('./', 'manifest.json')
@app.route('/') @app.route('/')
@ldap.login_required @ldap.login_required
def index(): def index():

+ 20
- 0
manifest.json View File

@ -0,0 +1,20 @@
{
"short_name": "Read TI Later",
"name": "Read TI Later",
"description": "Instapaper outdated. Pocket overrated. Long have we waited. Read TI Later ACTIVATED.",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/"
}

BIN
pocket/readitlater.db View File


+ 4
- 0
static/add_modal.js View File

@ -2,6 +2,10 @@ function openLinkModal() {
$('#addLinkModal').modal('show'); $('#addLinkModal').modal('show');
} }
function refreshPage() {
window.location.reload();
}
function addUrl() { function addUrl() {
$("#link-btn").prop("disabled", true); $("#link-btn").prop("disabled", true);

BIN
static/read-it-later.png View File

Before After
Width: 1024  |  Height: 1024  |  Size: 43 KiB

+ 68
- 1
static/style.css View File

@ -1,5 +1,21 @@
html {
width: 100%;
height: 100%;
overflow: hidden;
position: fixed;
}
.navbar {
position: absolute;
top: 0;
width: 100%;
}
.wrapper { .wrapper {
display: flex;
height: calc(100% - 56px);
overflow: auto;
position: fixed;
top: 56px;
width: 100%; width: 100%;
align-items: stretch; align-items: stretch;
} }
@ -206,6 +222,57 @@
} }
} }
@media all and (display-mode: standalone) {
.navbar {
position: absolute;
top: 0;
width: 100%;
padding-top: 44px !important;
}
#refreshButton {
display: block !important;
}
.wrapper {
height: calc(100% - 92px);
overflow: auto;
position: fixed;
top: 92px;
width: 100%;
align-items: stretch;
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-insert-bottom);
}
@media (min-width: 577px) {
.navbar {
position: absolute;
top: 0;
width: 100%;
padding-top: 24px !important;
}
#navbarNavDropdown {
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}
.wrapper {
height: calc(100% - 72px);
overflow: auto;
position: fixed;
top: 72px;
width: 100%;
align-items: stretch;
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-insert-bottom);
}
}
}
@media (max-width: 991.98px) { @media (max-width: 991.98px) {
#sidebar { #sidebar {
display: none !important; display: none !important;

+ 10
- 1
templates/article.j2 View File

@ -1,6 +1,15 @@
{% extends "bootstrap/base.html" %} {% extends "bootstrap/base.html" %}
{% block title %}Read TI Later{% endblock %} {% block title %}Read TI Later{% endblock %}
{% block metas %}
{{super()}}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<link rel="manifest" crossorigin="use-credentials" href="./manifest.json">
<link rel="apple-touch-icon" href="{{url_for('.static', filename='read-it-later.png')}}">
{% endblock %}
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}"> <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
@ -63,7 +72,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="container" style="margin-top: 15px">
<div class="container wrapper" style="padding-left: 15px !important; padding-right: 15px !important; margin-right: auto !important; margin-left: auto !important; left: 0; right: 0;">
<div id="error-alert" class="alert alert-danger" role="alert" style="display: none;"> <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;">
This is a danger alert—check it out! This is a danger alert—check it out!
</div> </div>

+ 9
- 0
templates/bookmarklet.j2 View File

@ -1,6 +1,15 @@
{% extends "bootstrap/base.html" %} {% extends "bootstrap/base.html" %}
{% block title %}Read TI Later{% endblock %} {% block title %}Read TI Later{% endblock %}
{% block metas %}
{{super()}}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<link rel="manifest" crossorigin="use-credentials" href="./manifest.json">
<link rel="apple-touch-icon" href="{{url_for('.static', filename='read-it-later.png')}}">
{% endblock %}
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}"> <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">

+ 3
- 0
templates/fragments/navbar.j2 View File

@ -29,7 +29,10 @@
</li> </li>
</ul> </ul>
<form class="form-inline ml-auto"> <form class="form-inline ml-auto">
{% if request.path != url_for('bookmarklet') %}
<a class="btn btn-success" id="refreshButton" href="#refresh" onclick="refreshPage();" role="button" style="margin-right: 20px; display: none;">Refresh</a>
<a class="btn btn-info" href="#addLink" onclick="openLinkModal();" role="button" style="margin-right: 20px;">Add Link</a> <a class="btn btn-info" href="#addLink" onclick="openLinkModal();" role="button" style="margin-right: 20px;">Add Link</a>
{% endif %}
<a class="btn btn-primary" href="/logout" role="button">Logout</a> <a class="btn btn-primary" href="/logout" role="button">Logout</a>
</form> </form>
</div> </div>

+ 10
- 0
templates/list.j2 View File

@ -1,6 +1,15 @@
{% extends "bootstrap/base.html" %} {% extends "bootstrap/base.html" %}
{% block title %}Read TI Later{% endblock %} {% block title %}Read TI Later{% endblock %}
{% block metas %}
{{super()}}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<link rel="manifest" crossorigin="use-credentials" href="./manifest.json">
<link rel="apple-touch-icon" href="{{url_for('.static', filename='read-it-later.png')}}">
{% endblock %}
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}"> <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
@ -45,5 +54,6 @@
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
{# <script src="{{url_for('.static', filename='inobounce.js')}}"></script> #}
<script type="text/javascript" src="{{url_for('.static', filename='add_modal.js')}}"></script> <script type="text/javascript" src="{{url_for('.static', filename='add_modal.js')}}"></script>
{% endblock %} {% endblock %}

+ 12
- 1
templates/login.j2 View File

@ -1,5 +1,14 @@
{% extends "bootstrap/base.html" %} {% extends "bootstrap/base.html" %}
{% block title %}Technical Incompetence Link Shortener{% endblock %}
{% block title %}Read TI Later{% endblock %}
{% block metas %}
{{super()}}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<link rel="manifest" crossorigin="use-credentials" href="./manifest.json">
<link rel="apple-touch-icon" href="{{url_for('.static', filename='read-it-later.png')}}">
{% endblock %}
{% block styles %} {% block styles %}
{{super()}} {{super()}}
@ -13,6 +22,7 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="wrapper">
<div class="container" style="margin-top: 15px"> <div class="container" style="margin-top: 15px">
<div class="jumbotron"> <div class="jumbotron">
<h1>Sign in for our awesome service</h1> <h1>Sign in for our awesome service</h1>
@ -34,4 +44,5 @@
<button type="submit" class="btn btn-primary">Log In</button> <button type="submit" class="btn btn-primary">Log In</button>
</form> </form>
</div> </div>
</div>
{% endblock %} {% endblock %}

Loading…
Cancel
Save