Changes in directory structures. Notes are now aware of their authors.
2
note.py
|
@ -19,7 +19,7 @@ def convert_datestring_to_date(datestring):
|
||||||
day = datestring[0:2]
|
day = datestring[0:2]
|
||||||
else:
|
else:
|
||||||
day = "0" + datestring[0:1]
|
day = "0" + datestring[0:1]
|
||||||
months = {"stycznia" : "01", "lutego" : "02", "marca" : "03", "kwietnia" : "04", "maja" : "05", "czerwca" : "06",
|
months = {"stycznia" : "01", "lutego" : "02", "luty" : "02", "marca" : "03", "kwietnia" : "04", "maja" : "05", "czerwca" : "06",
|
||||||
"lipca" : "07", "sierpnia" : "08", "wrzesnia" : "09", "padziernik": "10", "padziernika" : "10", "listopada" : "11", "grudnia" : "12"}
|
"lipca" : "07", "sierpnia" : "08", "wrzesnia" : "09", "padziernik": "10", "padziernika" : "10", "listopada" : "11", "grudnia" : "12"}
|
||||||
month = ""
|
month = ""
|
||||||
for m in months.keys():
|
for m in months.keys():
|
||||||
|
|
|
@ -4,7 +4,8 @@ import sqlite3
|
||||||
|
|
||||||
DATABASE = 'notes.db'
|
DATABASE = 'notes.db'
|
||||||
|
|
||||||
def add_all_notes_in_dir(path):
|
def add_all_notes_in_dir(path, author):
|
||||||
|
print "[+] adding notes from directory: " + path
|
||||||
subjects = os.listdir(path)
|
subjects = os.listdir(path)
|
||||||
if "bootstrap" in subjects:
|
if "bootstrap" in subjects:
|
||||||
subjects.remove("bootstrap")
|
subjects.remove("bootstrap")
|
||||||
|
@ -13,24 +14,26 @@ def add_all_notes_in_dir(path):
|
||||||
if ".directory" in subjects:
|
if ".directory" in subjects:
|
||||||
subjects.remove(".directory")
|
subjects.remove(".directory")
|
||||||
print "all subjects: " + str(subjects)
|
print "all subjects: " + str(subjects)
|
||||||
|
author_string = path.split("/")[-1]
|
||||||
|
print "[info] author string is " + author_string
|
||||||
for subject in subjects:
|
for subject in subjects:
|
||||||
for date in os.listdir(path+"/" + subject):
|
for date in os.listdir(path+"/" + subject):
|
||||||
notes = []
|
notes = []
|
||||||
for note in os.listdir(path+"/" + subject +"/" + date ):
|
for note in os.listdir(path+"/" + subject +"/" + date ):
|
||||||
notes.append({"tags": "none", "name": note})
|
notes.append({"tags": "none", "name": note})
|
||||||
print subject + " " + date + note
|
print subject + " " + date + note
|
||||||
add_note(subject, date, notes)
|
add_note(subject, date, notes, author, author_string)
|
||||||
|
|
||||||
|
|
||||||
def add_note(subject, datestring, notes):
|
def add_note(subject, datestring, notes, author, author_string):
|
||||||
connection_db = connect_db()
|
connection_db = connect_db()
|
||||||
db = connection_db.cursor()
|
db = connection_db.cursor()
|
||||||
db.execute('insert into notes (subject, datestring ) values (?, ?)', [subject, datestring])
|
db.execute('insert into notes (subject, datestring, author, author_string ) values (?, ?, ?, ?)', [subject, datestring, author, author_string])
|
||||||
note_id = db.lastrowid
|
note_id = db.lastrowid
|
||||||
for note in notes:
|
for note in notes:
|
||||||
db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
|
db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
|
||||||
connection_db.commit()
|
connection_db.commit()
|
||||||
print "note added"
|
print "[+] note added"
|
||||||
|
|
||||||
def connect_db():
|
def connect_db():
|
||||||
return sqlite3.connect(DATABASE)
|
return sqlite3.connect(DATABASE)
|
||||||
|
@ -38,7 +41,7 @@ def connect_db():
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
db = connect_db()
|
db = connect_db()
|
||||||
print "initialize database..."
|
print "[+] initialize database..."
|
||||||
f = open("schema.sql", "r")
|
f = open("schema.sql", "r")
|
||||||
db.cursor().executescript(f.read())
|
db.cursor().executescript(f.read())
|
||||||
db.commit()
|
db.commit()
|
||||||
|
@ -46,8 +49,9 @@ def init_db():
|
||||||
def main():
|
def main():
|
||||||
init_db()
|
init_db()
|
||||||
path = raw_input("Path: ")
|
path = raw_input("Path: ")
|
||||||
|
author = raw_input("Author: ")
|
||||||
try:
|
try:
|
||||||
add_all_notes_in_dir(path)
|
add_all_notes_in_dir(path, author)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
16
notes.py
|
@ -83,7 +83,7 @@ def home(subject= "mechanika", datestring= "14grudnia2012"):
|
||||||
|
|
||||||
@app.route('/subject/<subject>')
|
@app.route('/subject/<subject>')
|
||||||
def show_subject(subject):
|
def show_subject(subject):
|
||||||
dates = [date["datestring"] for date in get_possible_dates(subject)]
|
dates = prepare_other_dates(subject)
|
||||||
all_dates = prepare_all_dates()
|
all_dates = prepare_all_dates()
|
||||||
all_subjects = [sub["subject"] for sub in get_all_subjects()]
|
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)
|
return render_template('subject.html', subject=subject, dates=dates, all_dates=all_dates, all_subjects=all_subjects)
|
||||||
|
@ -121,9 +121,9 @@ def add_note(subject, datestring, notes):
|
||||||
g.db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
|
g.db.execute('insert into pages (note_id, name, tags ) values (?, ?, ?)', [note_id, note["name"], note["tags"]])
|
||||||
g._db.commit()
|
g._db.commit()
|
||||||
|
|
||||||
def create_thumb(subject, datestring, name, tags):
|
def create_thumb(subject, datestring, name, tags, author_string):
|
||||||
src = subject + "/" + datestring + "/" + name
|
src = "notes/" + author_string + "/mini/" + subject + "/" + datestring + "/" + name
|
||||||
href = src
|
href = "notes/" + author_string + "/" + subject + "/" + datestring + "/" + name
|
||||||
thumb = Thumb(src, href, tags)
|
thumb = Thumb(src, href, tags)
|
||||||
return thumb
|
return thumb
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ def get_thumbs(subject, datestring=""):
|
||||||
if(datestring==""):
|
if(datestring==""):
|
||||||
query_result = query_db("select pages.* from pages left join notes on notes.id = pages.note_id where notes.subject = ?", [subject,])
|
query_result = query_db("select pages.* from pages left join notes on notes.id = pages.note_id where notes.subject = ?", [subject,])
|
||||||
else:
|
else:
|
||||||
query_result = query_db("select pages.* from pages left join notes on notes.id = pages.note_id \
|
query_result = query_db("select pages.*, notes.author_string from pages left join notes on notes.id = pages.note_id \
|
||||||
where notes.subject = ? and datestring = ?", [subject, datestring])
|
where notes.subject = ? and datestring = ?", [subject, datestring])
|
||||||
return [create_thumb(subject, datestring, t["name"], t["tags"]) for t in query_result ]
|
return [create_thumb(subject, datestring, t["name"], t["tags"], t["author_string"]) for t in query_result ]
|
||||||
|
|
||||||
def get_possible_dates(subject):
|
def get_possible_dates(subject):
|
||||||
dates = query_db("select distinct datestring from notes where subject = ? ", [subject])
|
dates = query_db("select distinct datestring from notes where subject = ? ", [subject])
|
||||||
|
@ -141,9 +141,9 @@ def get_possible_dates(subject):
|
||||||
|
|
||||||
def get_notes_for_day(datestring):
|
def get_notes_for_day(datestring):
|
||||||
"""return pages which where written that day (daystring) with other info"""
|
"""return pages which where written that day (daystring) with other info"""
|
||||||
query_result = query_db("select pages.*,notes.subject from pages left join notes on notes.id = pages.note_id \
|
query_result = query_db("select pages.*,notes.subject,notes.author_string, notes.author from pages left join notes on notes.id = pages.note_id \
|
||||||
where datestring = ?", [datestring])
|
where datestring = ?", [datestring])
|
||||||
return [{"subject": t["subject"], "datestring": datestring, "name": t["name"]}for t in query_result ]
|
return [{"subject": t["subject"], "author_string":t["author_string"], "author":t["author"], "datestring": datestring, "name": t["name"]}for t in query_result ]
|
||||||
|
|
||||||
def get_all_dates():
|
def get_all_dates():
|
||||||
"""return all dates from database"""
|
"""return all dates from database"""
|
||||||
|
|
|
@ -8,6 +8,8 @@ tags string not null
|
||||||
create table if not exists notes (
|
create table if not exists notes (
|
||||||
id integer primary key autoincrement,
|
id integer primary key autoincrement,
|
||||||
subject string not null,
|
subject string not null,
|
||||||
|
author string not null,
|
||||||
|
author_string string not null,
|
||||||
datestring string not null
|
datestring string not null
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
|
@ -656,8 +656,9 @@ h4 small {
|
||||||
}
|
}
|
||||||
.page-header {
|
.page-header {
|
||||||
padding-bottom: 12px;
|
padding-bottom: 12px;
|
||||||
margin: 26px 0 39px;
|
margin: 26px 0 29px;
|
||||||
border-bottom: 1px solid #eeeeee;
|
border-bottom: 2px solid #ccaaaa;
|
||||||
|
border-top: 2px solid #ccaaaa;
|
||||||
}
|
}
|
||||||
ul,
|
ul,
|
||||||
ol {
|
ol {
|
||||||
|
@ -2541,13 +2542,13 @@ table th[class*="span"],
|
||||||
padding: 19px;
|
padding: 19px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
background-color: #fff0f5;
|
background-color: #fff0f5;
|
||||||
border: 3px solid #b22222;
|
|
||||||
-webkit-border-radius: 4px;
|
-webkit-border-radius: 4px;
|
||||||
-moz-border-radius: 4px;
|
-moz-border-radius: 4px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
|
|
||||||
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
|
|
||||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
|
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
|
||||||
|
-moz-box-shadow: 8px 6px 20px #000000;
|
||||||
|
-webkit-box-shadow: 8px 6px 20px #000000;
|
||||||
|
box-shadow: 8px 6px 26px #000000;
|
||||||
}
|
}
|
||||||
.well blockquote {
|
.well blockquote {
|
||||||
border-color: #ddd;
|
border-color: #ddd;
|
||||||
|
@ -5077,13 +5078,15 @@ a.badge:hover {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.hero-unit {
|
.hero-unit {
|
||||||
padding: 60px;
|
padding: 30px;
|
||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
|
border-bottom: 2px solid #ccaaaa;
|
||||||
|
border-top: 2px solid #ccaaaa;
|
||||||
line-height: 39px;
|
line-height: 39px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
background-color: #eeeeee;
|
background-color: #ededed;
|
||||||
-webkit-border-radius: 6px;
|
-webkit-border-radius: 6px;
|
||||||
-moz-border-radius: 6px;
|
-moz-border-radius: 6px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>attero's portfolio</title>
|
||||||
|
<meta name="description" content="portfolio, projects, experience">
|
||||||
|
<meta name="author" content="attero">
|
||||||
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>portfolio</h1>
|
||||||
|
<script src="js/scripts.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 897 B |
After Width: | Height: | Size: 590 KiB |
After Width: | Height: | Size: 560 KiB |
After Width: | Height: | Size: 310 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 722 KiB |
After Width: | Height: | Size: 602 KiB |
After Width: | Height: | Size: 357 KiB |
After Width: | Height: | Size: 261 KiB |
After Width: | Height: | Size: 584 KiB |
After Width: | Height: | Size: 619 KiB |
After Width: | Height: | Size: 560 KiB |
After Width: | Height: | Size: 491 KiB |
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 256 KiB |
After Width: | Height: | Size: 240 KiB |
After Width: | Height: | Size: 243 KiB |
After Width: | Height: | Size: 143 KiB |
After Width: | Height: | Size: 333 KiB |
After Width: | Height: | Size: 286 KiB |
After Width: | Height: | Size: 746 KiB |
After Width: | Height: | Size: 567 KiB |
After Width: | Height: | Size: 649 KiB |
After Width: | Height: | Size: 635 KiB |
After Width: | Height: | Size: 552 KiB |
After Width: | Height: | Size: 613 KiB |
After Width: | Height: | Size: 604 KiB |
After Width: | Height: | Size: 567 KiB |
After Width: | Height: | Size: 493 KiB |
After Width: | Height: | Size: 742 KiB |
After Width: | Height: | Size: 703 KiB |
After Width: | Height: | Size: 689 KiB |
After Width: | Height: | Size: 566 KiB |
After Width: | Height: | Size: 788 KiB |
After Width: | Height: | Size: 795 KiB |
After Width: | Height: | Size: 798 KiB |
After Width: | Height: | Size: 703 KiB |
After Width: | Height: | Size: 649 KiB |
After Width: | Height: | Size: 614 KiB |
After Width: | Height: | Size: 592 KiB |
After Width: | Height: | Size: 290 KiB |
After Width: | Height: | Size: 348 KiB |
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 838 KiB |
After Width: | Height: | Size: 869 KiB |
After Width: | Height: | Size: 788 KiB |
After Width: | Height: | Size: 826 KiB |
After Width: | Height: | Size: 655 KiB |
After Width: | Height: | Size: 589 KiB |
After Width: | Height: | Size: 599 KiB |
After Width: | Height: | Size: 590 KiB |
After Width: | Height: | Size: 578 KiB |
After Width: | Height: | Size: 757 KiB |
After Width: | Height: | Size: 789 KiB |
After Width: | Height: | Size: 787 KiB |
After Width: | Height: | Size: 710 KiB |
After Width: | Height: | Size: 454 KiB |
After Width: | Height: | Size: 436 KiB |
After Width: | Height: | Size: 390 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 667 KiB |
After Width: | Height: | Size: 631 KiB |
After Width: | Height: | Size: 650 KiB |
After Width: | Height: | Size: 617 KiB |
After Width: | Height: | Size: 668 KiB |
After Width: | Height: | Size: 347 KiB |
After Width: | Height: | Size: 616 KiB |
After Width: | Height: | Size: 157 KiB |
After Width: | Height: | Size: 792 KiB |
After Width: | Height: | Size: 736 KiB |
After Width: | Height: | Size: 749 KiB |
After Width: | Height: | Size: 644 KiB |
After Width: | Height: | Size: 618 KiB |
After Width: | Height: | Size: 644 KiB |
After Width: | Height: | Size: 601 KiB |
After Width: | Height: | Size: 563 KiB |
After Width: | Height: | Size: 740 KiB |
After Width: | Height: | Size: 778 KiB |
After Width: | Height: | Size: 732 KiB |
After Width: | Height: | Size: 703 KiB |
After Width: | Height: | Size: 689 KiB |
After Width: | Height: | Size: 714 KiB |
After Width: | Height: | Size: 692 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 663 KiB |
After Width: | Height: | Size: 538 KiB |
After Width: | Height: | Size: 393 KiB |