From 31b99fd614930c62261d9dc403009701b122b532 Mon Sep 17 00:00:00 2001 From: q Date: Sat, 9 Jul 2016 22:36:59 +0300 Subject: [PATCH] maybe more clear menu icon structure --- shop.py | 24 ++++++++++++++++++++---- static/script.js | 13 ++++++++----- static/style.css | 9 +++++++-- templates/layout.html | 3 ++- templates/show_shop.html | 31 ++++++++++++++++++------------- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/shop.py b/shop.py index 88484dd..ca74c21 100644 --- a/shop.py +++ b/shop.py @@ -66,6 +66,18 @@ def get_shop_date(id): os.path.getmtime(data_file)).strftime('%m/%d %H:%M') return date +def get_shop_backup_date(id): + date="" + cur = g.db.execute('select * from shops') + for row in cur.fetchall(): + if id==row[0]: + data_dir=os.path.join(DATADIR, get_username(row[2])) + data_file=os.path.join(data_dir, row[1]+".md.bkp") + if os.path.exists(data_file): + date=datetime.datetime.fromtimestamp( + os.path.getmtime(data_file)).strftime('%m/%d %H:%M') + return date + def scan_for_new_documents(id): user=get_username(id) data_dir=os.path.join(DATADIR, user) @@ -140,6 +152,8 @@ def show_shop(shopid): icon=u"\u2714" extra_class="" row=urlify(row).encode('ascii', 'xmlcharrefreplace') + if row.startswith("#"): + row=""+row+"" entries.append( dict(row=i, text=row, icon=icon, extra_class=extra_class) ) shared_to=[] cur = g.db.execute('select * from shares') @@ -147,7 +161,8 @@ def show_shop(shopid): if row[0]==shopid: shared_to.append(get_username(row[1])) return render_template('show_shop.html', entries=entries, shop=shopname, - shopid=shopid, content=content,shares=shared_to,date=get_shop_date(shopid)) + shopid=shopid, content=content,shares=shared_to, + date=get_shop_date(shopid),date_bkp=get_shop_backup_date(shopid)) @app.route('/') def list_shops(): @@ -247,6 +262,9 @@ def toggle_item(): for key in request.form: if key.startswith('item'): req_row=int(key[4:]) + if key=='toggleAll': + # Special meaning: toggle all rows + req_row=-1 if req_row==None: return redirect(url_for('show_shop',shopid=shopid)) data_dir=os.path.join(DATADIR, ownername) @@ -256,19 +274,17 @@ def toggle_item(): contents_file.close() changed=False for i,row in enumerate(contents): - if i==req_row: + if i==req_row or req_row==-1: if '[ ]' in row: contents[i]=row.replace('[ ]','[x]') if '[x]' in row: contents[i]=row.replace('[x]','[ ]') if row!=contents[i]: changed=True - break if changed: contents_file=open(data_file,'wt') contents_file.write("\n".join(contents).encode('utf-8')) contents_file.close() - #~ flash('successfully posted %s (%d)'%(row,req_row)) return redirect(url_for('show_shop',shopid=shopid)) @app.route('/remove_toggled', methods=['POST']) diff --git a/static/script.js b/static/script.js index ee08ebb..1f02ddc 100644 --- a/static/script.js +++ b/static/script.js @@ -33,14 +33,11 @@ function hideOthers(name) { } } function dropDown(name) { + dropDownHide(); document.getElementById(name).classList.toggle("show"); hideOthers('foo'); } - -// Close the dropdown menu if the user clicks outside of it -window.onclick = function(event) { - if (!event.target.matches('.dropbtn')) { - +function dropDownHide() { var dropdowns = document.getElementsByClassName("dropdown-content"); var i; for (i = 0; i < dropdowns.length; i++) { @@ -49,6 +46,12 @@ window.onclick = function(event) { openDropdown.classList.remove('show'); } } +} + +// Close the dropdown menu if the user clicks outside of it +window.onclick = function(event) { + if (!event.target.matches('.dropbtn')) { + dropDownHide(); } } diff --git a/static/style.css b/static/style.css index 3ee8329..be66b3d 100644 --- a/static/style.css +++ b/static/style.css @@ -6,6 +6,7 @@ h2 { font-size: 1.2em; border-top: 2px solid #eee; margin-top: 0.25 td { height: 1.75em; } textarea { border: 2px solid #ccc; } input[type=text]{ border: 2px solid #ccc; } +hr { border-color: #377ba8; } .submit { font-family: monospace; } .tickbox { margin-right: 0.5em; width:2em; height:1.8em; } @@ -32,7 +33,11 @@ input[type=text]{ border: 2px solid #ccc; } -moz-animation: notifier 500ms alternate infinite; -o-animation: notifier 500ms alternate infinite; animation: notifier 500ms alternate infinite; } -#date { font-size: 0.75em; margin-top: 1.2em; } +.date { font-size: 0.75em; margin-top: 1.2em; } + +/* MD rendering */ + +.md_head { color: #377ba8; font-weight: bold; } /* dropdown */ @@ -68,7 +73,7 @@ input[type=text]{ border: 2px solid #ccc; } /* Links inside the dropdown */ .dropdown-content a { - padding: 12px 16px; + padding: 8px 16px; display: block; } diff --git a/templates/layout.html b/templates/layout.html index 0dcc436..e0059c8 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -14,7 +14,7 @@
- Shops + MDShops