Development¶
Configuration¶
geekbook - config file
Geekbookapp¶
Page¶
Make Index¶
geekbook - make index
Get the list of md with sys.stdint.read() and generate html index.html. The top of the html file is defined here, see the html variable. The second part is generated in the loop, per md make a link in the index.html.
Make Table of Contents¶
geekbook - table of content
Get markdown output and make a table of content!
h1 How my lifebook should look? id_of_div How-my-lifebook-should-look?
changelog:
- 2012
- 0831 fix of the previous point
- 0829 make h1 clickable
Preprocessing¶
Postprocessing¶
This is a set of functions that work on HTML file, after compiling them based on Markdown.
-
engine.postprocessing.
change_data_tag_into_actual_data
(mdfn, text)[source]¶ change [date] OR {{date}} into actual date
searches for html tags and adds the proper bootstrap class
-
engine.postprocessing.
change_todo_square_chainbox_or_icon
(text, verbose=False)[source]¶ Set of rules to replace [i] etc with <img … > [ OK ]
-
engine.postprocessing.
get_captions
(text)[source]¶ Replace in text @todo, @inprogress and @done with <span class=”label label-danger”>@todo</span> and so on.
-
engine.postprocessing.
get_todo
(text)[source]¶ Replace in text @todo, @inprogress and @done with <span class=”label label-danger”>@todo</span> and so on.
It’s not changed in headers! See make_tableofcontent.py to change headers
insert here your personal tags!
-
engine.postprocessing.
use_icons
(text)[source]¶ https://www.w3schools.com/bootstrap/bootstrap_badges_labels.asp
Flask-based actions¶
Run the server:
[mm] geekbook git:(master) ✗ python engine/webserverflask.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
and open in your browser http://127.0.0.1:5000/edit/test.md (you can add this to your notes
<a href="http://127.0.0.1:5000/edit/test.md">edit</a>
.
To add new function, build on this simple example:
@app.route('/edit/<note_title>')
def edit(note_title):
"""Open a note with your edit"""
os.system('open ../notes/' + note_title)
return 'edit note: %s' % note_title
Webserver
# get ip of visitors https://stackoverflow.com/questions/3759981/get-ip-address-of-visitors
-
engine.webserverflask.
edit_header
(note_title, note_header, verbose=False)[source]¶ edit_header::cmd: cd /Users/magnus/Dropbox/geekbook/notes/ && /usr/bin/grep -n ‘# h1 Heading’ test.md edit_header::out: 11:# h1 Heading
Old: grep
grep -n ‘May #2’ *.md lifebook.md:7:# May # Open a note with your edit
http://stackoverflow.com/questions/3139970/open-a-file-at-line-with-filenameline-syntax
..warning: if two headers found there will be a problem ;-)
-
engine.webserverflask.
view
(note_title)[source]¶ Open a note with your edit http://flask.pocoo.org/snippets/76/
DataTables¶
Html code to be inserted dataTables [1] for index can be found in engine/make_index.py
.