summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-28 13:19:14 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-28 13:19:14 +0100
commit57f76f98ac9ea9ef73b665808ce772a17ad0d885 (patch)
tree4f118c9c4050fb5b9379379900b2eeedc9695aa3
parentb910e2649e87b9b52106a2c2c9fa7277f306b34c (diff)
downloadnooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.tar.gz
nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.tar.bz2
nooz-57f76f98ac9ea9ef73b665808ce772a17ad0d885.zip
Other dates in view are nice formatted.
-rw-r--r--note.py11
-rw-r--r--note.pycbin2032 -> 1873 bytes
-rw-r--r--notes.py17
-rw-r--r--templates/index.html35
4 files changed, 42 insertions, 21 deletions
diff --git a/note.py b/note.py
index fb51871..2029f93 100644
--- a/note.py
+++ b/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 \ No newline at end of file
diff --git a/note.pyc b/note.pyc
index d193b7a..f0c6012 100644
--- a/note.pyc
+++ b/note.pyc
Binary files differ
diff --git a/notes.py b/notes.py
index 82f6ef2..23fc292 100644
--- a/notes.py
+++ b/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]:
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>