maybe more clear menu icon structure

This commit is contained in:
q
2016-07-09 22:36:59 +03:00
parent 4e4a174338
commit 31b99fd614
5 changed files with 55 additions and 25 deletions

24
shop.py
View File

@@ -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="<span class=md_head>"+row+"</span>"
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'])

View File

@@ -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();
}
}

View File

@@ -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;
}

View File

@@ -14,7 +14,7 @@
<body>
<div class=page>
<div class=metanav>
<a href="{{ url_for('list_shops') }}" id="shopsList">Shops</a>
<a href="{{ url_for('list_shops') }}" id="shopsList">MDShops</a>
<span class="hspacer"></span>
<div class="dropdown">
<p onclick="dropDown('userAct')" class="dropbtn">&sube;&supe;</p>
@@ -29,6 +29,7 @@
<div class="dropdown">
<p onclick="dropDown('shopAct')" class="dropbtn">&#9757;&#9748;</p>
<div id="shopAct" class="dropdown-content">
<a id="h2_add" onclick="hidetoggle('disp_add')" class=pointer>&plusmn;&nbsp;Add/remove</a>
<a id="h2_sort" onclick="sortMarkdown()" class=pointer>&nbsp;Sort&nbsp;view</a>
<a id="h2_edit" onclick="hidetoggle('disp_edit');growTextarea('edit_md');" class=pointer>&#x270e;&nbsp;Edit&nbsp;items</a>
<a id="h2_share" onclick="hidetoggle('disp_share')" class=pointer>&#9823;&nbsp;Share&nbsp;shop</a>

View File

@@ -10,10 +10,11 @@
{% endfor %}
</div>
</form>
<div id=date>{{ date }}</div>
<div class=date>{{ date }}</div>
</div>
<div id=iconarea>
<span class=iconbox >&nbsp;</span>
<span class=iconbox>&nbsp;</span>
<span class=iconbox onclick="hidetoggle('disp_add')" title="Add/remove">&plusmn;</span>
<span class=iconbox onclick="reload();" title="Reload">&#x21bb;</span>
<span class=iconbox onclick="sortMarkdown()" title="Sort view"></span>
<span class=iconbox onclick="hidetoggle('disp_edit');growTextarea('edit_md');" title="Edit file">&#x270e;</span>
@@ -21,19 +22,23 @@
<span class=iconbox onclick="hidetoggle('disp_restore')" title="Restore">&#9851;</span>
<span class=iconbox onclick="hidetoggle('disp_delete')" title="Delete">&otimes;</span>
</div>
<h2 id="h2_add" onclick="hidetoggle('disp_add')" class=pointer>Add items</h2>
<form id="disp_add" name="area_add" action="{{ url_for('add_items') }}" method=post class=add-entry>
<hr>
<div id="disp_add">
<form name="area_add" action="{{ url_for('add_items') }}" method=post class=add-entry>
<dl>
<dt><textarea cols=40 rows=1 id=add_md name=add_md onkeyup="growTextarea('add_md')"></textarea><br><input type=hidden name=shopid value={{ shopid }}><input class=submit type=submit value=Add>
<dt><textarea cols=40 rows=1 id=add_md name=add_md onkeyup="growTextarea('add_md')"></textarea>
<dt><input type=hidden name=shopid value={{ shopid }}><input class="submit submitNextTo" type=submit value="Add items">
</dl>
</form>
<h2 id="h2_remove_toggled" onclick="hidetoggle('disp_remove_toggled')" class=pointer>Remove ticked</h2>
<form id=disp_remove_toggled action="{{ url_for('remove_toggled') }}" method=post class=add-entry>
<dl><input type=hidden name=shopid value={{ shopid }}><input class=submit type=submit value=Remove>
</dl></form>
<hr>
<form action="{{ url_for('remove_toggled') }}" method=post class=add-entry>
<dl><input type=hidden name=shopid value={{ shopid }}><input class=submit type=submit onclick="return confirm('Do you really want to remove ticked entries?');" value="Remove ticked">
</dl>
</form>
<form action="{{ url_for('toggle_item') }}" method=post class=add-entry>
<dl><input type=hidden name=shopid value="{{ shopid }}"><input class=submit type=submit name=toggleAll value="Invert selection">
</dl>
</form>
</div>
<form id="disp_edit" class=hidden name="area_edit" action="{{ url_for('edit_md') }}" method=post class=add-entry>
<dl>Edit content file:
<dt><textarea cols=40 rows=5 id=edit_md name=edit_md onkeyup="growTextarea('edit_md')">{{ content }}</textarea><br>
@@ -57,7 +62,7 @@
</form>
</div>
<form id="disp_restore" class=hidden action="{{ url_for('restore_md') }}" method=post class=add-entry>
<dl>Shop state is backed up with "Edit items" and "Remove ticked" actions.</dl>
<dl>Shop state is backed up with "Edit items" and "Remove ticked" actions. Last backup: <span class=date>{{ date_bkp }}</span></dl>
<dl><input type=hidden name=shopid value={{ shopid }}><input class="submit notify" type=submit value=Restore onclick="return confirm('Do you really want to restore previous version?');">
</dl></form>
<form id="disp_delete" class=hidden action="{{ url_for('remove_shop') }}" method=post class=add-entry>