summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-26 20:41:39 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-26 20:41:39 +0100
commitb0ed3cc8009f3459dc9a342c89c92f9f67c93b50 (patch)
tree063a888732e6a8c1ff12f6095eb51e10e85e0dbe
parente635ab2c1be54be8313c96787b33a4b1a44ad957 (diff)
downloadnooz-b0ed3cc8009f3459dc9a342c89c92f9f67c93b50.tar.gz
nooz-b0ed3cc8009f3459dc9a342c89c92f9f67c93b50.tar.bz2
nooz-b0ed3cc8009f3459dc9a342c89c92f9f67c93b50.zip
Submenus!
-rw-r--r--note.py46
-rw-r--r--note.pycbin0 -> 2032 bytes
-rw-r--r--notemanager.py7
-rw-r--r--notes.dbbin10240 -> 9216 bytes
-rw-r--r--notes.py53
-rw-r--r--static/chemia/12grudnia/0003.jpegbin708590 -> 0 bytes
-rw-r--r--static/chemia/12grudnia/0004.jpegbin714012 -> 0 bytes
-rw-r--r--static/chemia/19grudnia/0005.jpegbin402826 -> 0 bytes
-rw-r--r--static/chemia/19grudnia/0006.jpegbin408592 -> 0 bytes
-rw-r--r--static/chemia/28listopada/0005.jpegbin833285 -> 0 bytes
-rw-r--r--static/chemia/28listopada/0006.jpegbin797874 -> 0 bytes
-rw-r--r--static/chemia/28listopada/0007.jpegbin722599 -> 0 bytes
-rw-r--r--static/chemia/2stycznia/0017.jpegbin805257 -> 0 bytes
-rw-r--r--static/chemia/2stycznia/0018.jpegbin736575 -> 0 bytes
-rw-r--r--static/chemia/2stycznia/0019.jpegbin679037 -> 0 bytes
-rw-r--r--static/chemia/7listopada/0004.jpegbin657313 -> 0 bytes
-rw-r--r--static/chemia/7listopada/0005.jpegbin635721 -> 0 bytes
-rw-r--r--static/chemia/7listopada/0006.jpegbin571409 -> 0 bytes
-rw-r--r--static/chemia/9stycznia/0020.jpegbin776817 -> 0 bytes
-rw-r--r--static/chemia/9stycznia/0021.jpegbin653874 -> 0 bytes
-rw-r--r--static/chemia/kolokwia/1015_ch_wykl_kol2.jpgbin53421 -> 0 bytes
-rw-r--r--static/chemia/kolokwia/kolos_poprzedni_rok_a.jpgbin55785 -> 0 bytes
-rw-r--r--static/chemia/kolokwia/kolos_poprzedni_rok_b.jpgbin66408 -> 0 bytes
-rw-r--r--static/chemia/kolokwia/pytania_na_kolokwium.JPGbin1334529 -> 0 bytes
-rw-r--r--templates/index.html21
-rw-r--r--templates/layout.html64
26 files changed, 143 insertions, 48 deletions
diff --git a/note.py b/note.py
new file mode 100644
index 0000000..fb51871
--- /dev/null
+++ b/note.py
@@ -0,0 +1,46 @@
+from delorean import Delorean
+from delorean import parse
+
+class Note:
+ def __init__(self, datestring, author, subject, pages):
+ self.date = convert_datestring_to_date(datestring)
+ self.author = author
+ self.subject = subject
+ self.pages = pages
+
+
+
+class Page:
+ def __init__(self, source, tags):
+ self.source = source
+ self.tags = tags
+
+def convert_datestring_to_date(datestring):
+ day = ""
+ if datestring[0:2].isdigit():
+ day = datestring[0:2]
+ else:
+ day = "0" + datestring[0:1]
+ months = {"stycznia" : "01", "lutego" : "02", "marca" : "03", "kwietnia" : "04", "maja" : "05", "czerwca" : "06",
+ "lipca" : "07", "sierpnia" : "08", "wrzesnia" : "09", "padziernik": "10", "padziernika" : "10", "listopada" : "11", "grudnia" : "12"}
+ 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
new file mode 100644
index 0000000..d193b7a
--- /dev/null
+++ b/note.pyc
Binary files differ
diff --git a/notemanager.py b/notemanager.py
index be51026..e205939 100644
--- a/notemanager.py
+++ b/notemanager.py
@@ -8,11 +8,17 @@ def add_all_notes_in_dir(path):
subjects = os.listdir(path)
if "bootstrap" in subjects:
subjects.remove("bootstrap")
+ if "mini" in subjects:
+ subjects.remove("mini")
+ if ".directory" in subjects:
+ subjects.remove(".directory")
+ print "all subjects: " + str(subjects)
for subject in subjects:
for date in os.listdir(path+"/" + subject):
notes = []
for note in os.listdir(path+"/" + subject +"/" + date ):
notes.append({"tags": "none", "name": note})
+ print subject + " " + date + note
add_note(subject, date, notes)
@@ -24,6 +30,7 @@ def add_note(subject, datestring, notes):
for note in notes:
db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
connection_db.commit()
+ print "note added"
def connect_db():
return sqlite3.connect(DATABASE)
diff --git a/notes.db b/notes.db
index 8dd48fc..333f6e1 100644
--- a/notes.db
+++ b/notes.db
Binary files differ
diff --git a/notes.py b/notes.py
index 39a3f3d..8aeb179 100644
--- a/notes.py
+++ b/notes.py
@@ -10,6 +10,7 @@ import re
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
import smtplib
+from note import Note, Page, convert_datestring_to_date
# configuration
DATABASE = 'notes.db'
@@ -65,29 +66,66 @@ def teardown_request(exception):
@app.route('/')
@app.route('/view')
@app.route('/view/<subject>/<datestring>')
-def home(subject= "chemia", datestring= "12grudnia2012"):
+def home(subject= "mechanika", datestring= "14grudnia2012"):
other_dates = [date["datestring"] for date in get_possible_dates(subject)]
- all_dates = [date["datestring"] for date in get_all_dates()]
+ all_dates = prepare_all_dates()
all_subjects = [sub["subject"] for sub in get_all_subjects()]
+ thumbs = get_thumbs(subject, datestring)
if datestring in other_dates:
other_dates.remove(datestring)
thumbs_info = {"subject": subject, "datestring": datestring, "other_dates": other_dates}
- thumbs = get_thumbs(subject, datestring)
+
+ print thumbs
thumbs = [dict(href=thumb.href, src=thumb.src) for thumb in thumbs]
main_page_src=thumbs[0]["href"]
+ print all_dates
return render_template('index.html', thumbs=thumbs, main_page_src=main_page_src,thumbs_info=thumbs_info,
all_dates=all_dates, all_subjects=all_subjects)
+def prepare_all_dates():
+ 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]
+ sorted_dates = {}
+ for date, datestring in zip(all_dates, datastrings):
+ if not date.datetime.year in sorted_dates:
+ sorted_dates[date.datetime.year] = {}
+ if not date.datetime.month in sorted_dates[date.datetime.year]:
+ sorted_dates[date.datetime.year][date.datetime.month] = []
+ sorted_dates[date.datetime.year][date.datetime.month].append({"day" : date.datetime.day, "source": datestring,
+ "weekday": weekday(date.datetime.weekday())})
+ sorted = sort_number_strings(sorted_dates[date.datetime.year][date.datetime.month])
+ sorted_dates[date.datetime.year][date.datetime.month] = sorted
+ print sorted_dates
+ return sorted_dates
+
+def sort_number_strings(data):
+ number_data = [int(day["day"]) for day in data]
+ number_data.sort()
+ print "sorted date" + str(number_data)
+ return [{"day": number, "source": data[get_index_for(number, data)]["source"],
+ "weekday": data[get_index_for(number, data)]["weekday"] } for i, number in enumerate(number_data)]
+
+def weekday(number):
+ weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
+ return weekdays[number]
+def get_index_for(number, data):
+ index = 0
+ for i, day in enumerate(data):
+ if day["day"] == number:
+ index = i
+ return index
+
@app.route('/subject/<subject>')
def show_subject(subject):
dates = [date["datestring"] for date in get_possible_dates(subject)]
- all_dates = [date["datestring"] for date in get_all_dates()]
+ all_dates = prepare_all_dates()
all_subjects = [sub["subject"] for sub in get_all_subjects()]
return render_template('subject.html', subject=subject, dates=dates, all_dates=all_dates, all_subjects=all_subjects)
@app.route('/date/<datestring>')
def show_date(datestring):
- all_dates = [date["datestring"] for date in get_all_dates()]
+ all_dates = prepare_all_dates()
all_subjects = [sub["subject"] for sub in get_all_subjects()]
notes = get_notes_for_day(datestring)
separated_notes = {}
@@ -100,13 +138,13 @@ def show_date(datestring):
@app.route('/search')
def show_search():
- all_dates = [date["datestring"] for date in get_all_dates()]
+ all_dates = prepare_all_dates()
all_subjects = [sub["subject"] for sub in get_all_subjects()]
return render_template('search.html', all_dates=all_dates, all_subjects=all_subjects )
@app.route('/about')
def about():
- all_dates = [date["datestring"] for date in get_all_dates()]
+ all_dates = prepare_all_dates()
all_subjects = [sub["subject"] for sub in get_all_subjects()]
return render_template('about.html', all_dates=all_dates, all_subjects=all_subjects )
@@ -130,6 +168,7 @@ def get_thumbs(subject, datestring=""):
else:
query_result = query_db("select pages.* from pages left join notes on notes.id = pages.note_id \
where notes.subject = ? and datestring = ?", [subject, datestring])
+ print query_result
return [create_thumb(subject, datestring, t["name"], t["tags"]) for t in query_result ]
def get_possible_dates(subject):
diff --git a/static/chemia/12grudnia/0003.jpeg b/static/chemia/12grudnia/0003.jpeg
deleted file mode 100644
index 38da1a2..0000000
--- a/static/chemia/12grudnia/0003.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/12grudnia/0004.jpeg b/static/chemia/12grudnia/0004.jpeg
deleted file mode 100644
index fdf8726..0000000
--- a/static/chemia/12grudnia/0004.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/19grudnia/0005.jpeg b/static/chemia/19grudnia/0005.jpeg
deleted file mode 100644
index 8c1b0c1..0000000
--- a/static/chemia/19grudnia/0005.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/19grudnia/0006.jpeg b/static/chemia/19grudnia/0006.jpeg
deleted file mode 100644
index 6be72be..0000000
--- a/static/chemia/19grudnia/0006.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/28listopada/0005.jpeg b/static/chemia/28listopada/0005.jpeg
deleted file mode 100644
index 35f3399..0000000
--- a/static/chemia/28listopada/0005.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/28listopada/0006.jpeg b/static/chemia/28listopada/0006.jpeg
deleted file mode 100644
index 471bf1b..0000000
--- a/static/chemia/28listopada/0006.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/28listopada/0007.jpeg b/static/chemia/28listopada/0007.jpeg
deleted file mode 100644
index 5943bc3..0000000
--- a/static/chemia/28listopada/0007.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/2stycznia/0017.jpeg b/static/chemia/2stycznia/0017.jpeg
deleted file mode 100644
index b7f0e7c..0000000
--- a/static/chemia/2stycznia/0017.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/2stycznia/0018.jpeg b/static/chemia/2stycznia/0018.jpeg
deleted file mode 100644
index 4577353..0000000
--- a/static/chemia/2stycznia/0018.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/2stycznia/0019.jpeg b/static/chemia/2stycznia/0019.jpeg
deleted file mode 100644
index f495d7f..0000000
--- a/static/chemia/2stycznia/0019.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/7listopada/0004.jpeg b/static/chemia/7listopada/0004.jpeg
deleted file mode 100644
index d5af800..0000000
--- a/static/chemia/7listopada/0004.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/7listopada/0005.jpeg b/static/chemia/7listopada/0005.jpeg
deleted file mode 100644
index fdbc197..0000000
--- a/static/chemia/7listopada/0005.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/7listopada/0006.jpeg b/static/chemia/7listopada/0006.jpeg
deleted file mode 100644
index 4f3ec85..0000000
--- a/static/chemia/7listopada/0006.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/9stycznia/0020.jpeg b/static/chemia/9stycznia/0020.jpeg
deleted file mode 100644
index d1119c5..0000000
--- a/static/chemia/9stycznia/0020.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/9stycznia/0021.jpeg b/static/chemia/9stycznia/0021.jpeg
deleted file mode 100644
index b1ebd94..0000000
--- a/static/chemia/9stycznia/0021.jpeg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/kolokwia/1015_ch_wykl_kol2.jpg b/static/chemia/kolokwia/1015_ch_wykl_kol2.jpg
deleted file mode 100644
index 8a04e0d..0000000
--- a/static/chemia/kolokwia/1015_ch_wykl_kol2.jpg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/kolokwia/kolos_poprzedni_rok_a.jpg b/static/chemia/kolokwia/kolos_poprzedni_rok_a.jpg
deleted file mode 100644
index 54e25b7..0000000
--- a/static/chemia/kolokwia/kolos_poprzedni_rok_a.jpg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/kolokwia/kolos_poprzedni_rok_b.jpg b/static/chemia/kolokwia/kolos_poprzedni_rok_b.jpg
deleted file mode 100644
index 8a93df8..0000000
--- a/static/chemia/kolokwia/kolos_poprzedni_rok_b.jpg
+++ /dev/null
Binary files differ
diff --git a/static/chemia/kolokwia/pytania_na_kolokwium.JPG b/static/chemia/kolokwia/pytania_na_kolokwium.JPG
deleted file mode 100644
index 7c7c1c9..0000000
--- a/static/chemia/kolokwia/pytania_na_kolokwium.JPG
+++ /dev/null
Binary files differ
diff --git a/templates/index.html b/templates/index.html
index 6fd0401..c43bf33 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -19,6 +19,15 @@ $("document").ready( function(){
$('#display').hide();
$('#display').fadeIn('slow');
$('#display').attr("src", image);
+ i = $(this).data("number");
+ console.log(i);
+ next_page = pages[i];
+ console.log("next: " + next_page)
+ if(i >= 2)
+ {
+ previous_page = pages[i - 2];
+ console.log("previous: " + previous_page)
+ }
return false;
});
@@ -34,12 +43,9 @@ $("document").ready( function(){
$('#display').fadeIn('slow');
$('#display').attr("src", next_page);
- i++;
+ i++;
next_page = pages[i];
-
-
}
-
return false;
});
$("#older").click(function() {
@@ -52,8 +58,6 @@ $("document").ready( function(){
previous_page = pages[i-3];
next_page = pages[i-1]
i--;
-
-
}
return false;
});
@@ -80,8 +84,9 @@ $("document").ready( function(){
</li>
<li class="span2">
- {% for thumb in thumbs %}
- <a href="#" rel="{{ url_for('static', filename=thumb.href) }}" class="thumbnail image">
+ {% for thumb in thumbs %}
+ <a href="#" rel="{{ url_for('static', filename=thumb.href) }}" class="thumbnail image"
+ data-number="{{loop.index}}">
<img src="{{ url_for('static', filename='mini/' + thumb.src) }}" alt="">
</a>
{% endfor %}
diff --git a/templates/layout.html b/templates/layout.html
index 4852773..86ebdd5 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -47,7 +47,7 @@ $("document").ready( function() {
border-radius: 3px;
display: block;
left: 95%;
- margin-top: -30px !important;
+ margin-top: -50px !important;
moz-border-radius: 3px;
position: absolute;
webkit-border-radius: 3px;
@@ -129,43 +129,41 @@ $("document").ready( function() {
<li>n</li>
</ul>
</li>
- {% for date in all_dates %}
- <li><a href="/date/{{date }}">{{date }}</a> </li>
- {% endfor %}
+
<li>
</li>
-
-
</ul>
<ul class="dropdown-menu">
- <li class="dropdown submenu">
- <a href="#" class="dropdown-toggle" id="levelone" data-toggle="dropdown">Level 1</a>
- <ul class="dropdown-menu submenu-hide">
- <li class="dropdown submenu">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">Level 1.1</a>
- <ul class="dropdown-menu submenu-show submenu-hide">
- <li><a href="#">Level 1.1.1</a></li>
- <li><a href="#">Level 1.1.2</a></li>
- <li><a href="#">Level 1.1.3</a></li>
- <li><a href="#">Level 1.1.4</a></li>
- </ul>
- </li>
- <li class="dropdown submenu">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">Level 1.2</a>
- <ul class="dropdown-menu submenu-hide">
- <li><a href="#">Level 1.2.1</a></li>
- <li><a href="#">Level 1.2.2</a></li>
- </ul>
- </li>
- <li><a href="#">Level 1.3</a></li>
- <li><a href="#">Level 1.4</a></li>
- <li><a href="#">Level 1.5</a></li>
- </ul>
- </li>
- {% for date in all_dates %}
- <li><a href="/date/{{date }}">{{date }}</a> </li>
- {% endfor %}
+ <li class="nav-header">Year</li>
+ {%- for key, year in all_dates.items() recursive %}
+
+ <li class="dropdown submenu">
+
+ <a href="#" class="dropdown-toggle" id="{{key}}" data-toggle="dropdown">{{key}}</a>
+ {%- if year %}
+
+ <ul class="dropdown-menu submenu-hide">
+ <li class="nav-header">Month</li>
+ {% for month, days in year.items() %}
+
+ <li class="dropdown submenu">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{month}}</a>
+
+ <ul class="dropdown-menu submenu-show submenu-hide">
+ <li class="nav-header">Day</li>
+ {% for day in days %}
+ <li><a href="/date/{{day.source}}">{{day.weekday}}, {{day.day}}</a></li>
+ {% endfor %}
+ </ul>
+ </li>
+ {% endfor %}
+ </ul>
+
+ {%-endif%}
+ </li>
+ {%- endfor %}
+
</ul>
</div>
</ul>