Other dates in view are nice formatted.
parent
b910e2649e
commit
57f76f98ac
11
note.py
11
note.py
|
@ -8,8 +8,6 @@ class Note:
|
|||
self.subject = subject
|
||||
self.pages = pages
|
||||
|
||||
|
||||
|
||||
class Page:
|
||||
def __init__(self, source, tags):
|
||||
self.source = source
|
||||
|
@ -26,21 +24,12 @@ def convert_datestring_to_date(datestring):
|
|||
month = ""
|
||||
for m in months.keys():
|
||||
if m in datestring:
|
||||
print "m is " + m
|
||||
month = months[m]
|
||||
print month
|
||||
|
||||
|
||||
if datestring[-4:].isdigit():
|
||||
year = datestring[-4:]
|
||||
else:
|
||||
year = "2013"
|
||||
if month == "":
|
||||
print "unknown: " + datestring
|
||||
month = "01"
|
||||
date = parse("-".join([year, month, day]))
|
||||
print "date is: " + str(date)
|
||||
print date.datetime.year
|
||||
print date.datetime.month
|
||||
print date.datetime.day
|
||||
return date
|
17
notes.py
17
notes.py
|
@ -67,7 +67,7 @@ def teardown_request(exception):
|
|||
@app.route('/view')
|
||||
@app.route('/view/<subject>/<datestring>')
|
||||
def home(subject= "mechanika", datestring= "14grudnia2012"):
|
||||
other_dates = [date["datestring"] for date in get_possible_dates(subject)]
|
||||
other_dates = prepare_other_dates(subject)
|
||||
all_dates = prepare_all_dates()
|
||||
all_subjects = [sub["subject"] for sub in get_all_subjects()]
|
||||
thumbs = get_thumbs(subject, datestring)
|
||||
|
@ -157,11 +157,18 @@ def get_all_subjects():
|
|||
|
||||
def prepare_all_dates():
|
||||
"""return all dates in well formated form of nested dictionaries"""
|
||||
all_dates = [date["datestring"] for date in get_all_dates()]
|
||||
datastrings = [date["datestring"] for date in get_all_dates()]
|
||||
all_dates = [convert_datestring_to_date(date) for date in datastrings]
|
||||
datestrings = [date["datestring"] for date in get_all_dates()]
|
||||
all_dates = [convert_datestring_to_date(date) for date in datestrings]
|
||||
return sort_dates(datestrings, all_dates)
|
||||
|
||||
def prepare_other_dates(subject):
|
||||
datestrings = [date["datestring"] for date in get_possible_dates(subject)]
|
||||
dates = [convert_datestring_to_date(date) for date in datestrings]
|
||||
return sort_dates(datestrings, dates)
|
||||
|
||||
def sort_dates(datestrings, dates):
|
||||
sorted_dates = {}
|
||||
for date, datestring in zip(all_dates, datastrings):
|
||||
for date, datestring in zip(dates, datestrings):
|
||||
if not date.datetime.year in sorted_dates:
|
||||
sorted_dates[date.datetime.year] = {}
|
||||
if not date.datetime.month in sorted_dates[date.datetime.year]:
|
||||
|
|
|
@ -90,14 +90,39 @@ $("document").ready( function(){
|
|||
<img src="{{ url_for('static', filename='mini/' + thumb.src) }}" alt="">
|
||||
</a>
|
||||
{% endfor %}
|
||||
<ul>
|
||||
<ul class="nav nav-pills">
|
||||
<h4>Other dates...</h4>
|
||||
{% for date in thumbs_info.other_dates %}
|
||||
<li><a href="/view/{{thumbs_info.subject}}/{{date }}">{{date }}</a> </li>
|
||||
{% endfor %}
|
||||
<ul class="nav nav-pills">
|
||||
{%- for key, year in thumbs_info.other_dates.items() recursive %}
|
||||
{%- if year %}
|
||||
<li> <a href="#">{{key}}</a>
|
||||
<ul class="nav nav-pills">
|
||||
|
||||
{% for month, days in year.items() %}
|
||||
<li>
|
||||
<a href="#" class=" disabled"> ->{{month}}</a>
|
||||
<ul class="nav nav-pills">
|
||||
{% for day in days %}
|
||||
{%- if day.source == thumbs_info.datestring%}
|
||||
<li>
|
||||
<a class="alert-danger" href="/view/{{thumbs_info.subject}}/{{day.source}}">
|
||||
--> {{day.weekday}}, {{day.day}}
|
||||
</a>
|
||||
</li>
|
||||
{%- else %}
|
||||
<li><a href="/view/{{thumbs_info.subject}}/{{day.source}}"> --> {{day.weekday}}, {{day.day}}</a></li>
|
||||
{%-endif%}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{%-endif%}
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue