diff options
author | Justyna Ilczuk <justyna.ilczuk@gmail.com> | 2013-01-28 13:19:14 +0100 |
---|---|---|
committer | Justyna Ilczuk <justyna.ilczuk@gmail.com> | 2013-01-28 13:19:14 +0100 |
commit | 57f76f98ac9ea9ef73b665808ce772a17ad0d885 (patch) | |
tree | 4f118c9c4050fb5b9379379900b2eeedc9695aa3 | |
parent | b910e2649e87b9b52106a2c2c9fa7277f306b34c (diff) | |
download | nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.tar.gz nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.tar.bz2 nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.tar.xz nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.zip |
Other dates in view are nice formatted.
-rw-r--r-- | note.py | 11 | ||||
-rw-r--r-- | note.pyc | bin | 2032 -> 1873 bytes | |||
-rw-r--r-- | notes.py | 17 | ||||
-rw-r--r-- | templates/index.html | 35 |
4 files changed, 42 insertions, 21 deletions
@@ -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
\ No newline at end of file Binary files differ@@ -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]: diff --git a/templates/index.html b/templates/index.html index ebff1b3..e43c619 100644 --- a/templates/index.html +++ b/templates/index.html @@ -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> |