Skip to content

Commit

Permalink
Add a template system
Browse files Browse the repository at this point in the history
  • Loading branch information
lchen198 committed Jul 23, 2021
1 parent 1159df5 commit e5b419f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The Built-in Calendar
* Runs on Mac, Linux and Windows.
* A built-in calendar and daily journal.
* A GetThingsDone template to help you setup your GTD system quickly.
* A tempalte system that automatically inserts pre-defined content into new wiki pages.
* Full-text search.
* A modernized and mobile-friendly look using [Sakura CSS](https://github.com/oxalorg/sakura).
* Wiki pages save to plain text files under the "w" directory
Expand Down Expand Up @@ -107,6 +108,11 @@ There's no difference between Tags and WikiWords. When you create a new page, th
For example, you can create a page called ToDo, and put the word ToDo to other pages and see references here:
http://127.0.0.1:8000/cgi-bin/wypyplus?p=ToDo&q=f

### How to define and use a tempalte
You can create a template just like any other wiki page. A tempalte name must start with "Tpl" and follow by three characters. WyPyPlus will automatically insert its content to a new wiki page when the first three characters of the page matche the tempalte.

For example, If you create a template page called TplJan, a new page called Jan23 will load the content from template.

# Source Code

The original wypy code is highly compressed. However, variable names are carefully picked so that the code is still somewhat readable.
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/wypyplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
pre='(?:^|\n)```((?:.|\n)+?)\n```';link='\[([^]]*)]\(\s*((?:http[s]?://)?[^)]+)\s*\)';import sys,re,os,cgi;
from datetime import timedelta as td,datetime as dt;q,x,h,w=cgi.escape,os.path.exists,'<a href=','wypyplus.py?p='
load,t=lambda n:(x('w/'+n) and open('w/'+n).read()) or '','</textarea>'
load,t=lambda n:(x('w/'+n) and open('w/'+n).read()) or (x('w/'+'Tpl'+n[:3]) and open('w/'+'Tpl'+n[:3]).read()) or '','</textarea>'
f,i=cgi.FormContent(),'put type';y=f.get('p',[''])[0];y=('WyPyPlus',y)[y.isalnum()]
fs,do,main=lambda s:re.sub('^ #', '#',reduce(lambda s,r:re.sub('(?m)'+r[0],r[1],s),(('\r',''),(\
'(^|[^=/\-_A-Za-z0-9?])([A-Z][a-z]+([A-Z0-9][a-z0-9]*){1,})',lambda m:(m.group(1)+'%s'+h+w+m.group(2)+\
Expand Down
6 changes: 6 additions & 0 deletions w/DemoPage
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Markdown link: [google homepage](http://google.com)

Reference to a date or a month: Jan1 Jan2021

## Template

A template is a page with a special name: Tpl[three characters]. A page starts with the same three characters will use the template.

For example, when you create TplJan, Any page starts with "Jan" such as Jan21 will include the template.

## Images

YouTube Video:
Expand Down
12 changes: 9 additions & 3 deletions w/WyPyPlus
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ WyPyPlus (pronounced "whippy plus") is a minimalist wiki server in 23 lines of c

## New Features:
* Only 23 lines of Python code with no external dependency other than the standard library.
* A built-in calendar: Calendar2021
* A GetThingsDone template to help you setup your GTD system quickly.
* Runs on Mac, Linux and Windows.
* A built-in calendar and daily journal.
* A GetThingsDone template to help you setup your GTD system quickly.
* A tempalte system that automatically inserts pre-defined content into new wiki pages.
* Full-text search.
* A modernized and mobile-friendly look using [Sakura CSS](https://github.com/oxalorg/sakura).
* Wiki pages save to plain text files under the "w" directory
* Delete a wiki page from disk by saving an empty content.
* Support common markdown syntax such as headline style and links [DemoPage](https://github.com/lchen198/wypyplus/blob/main/w/DemoPage).
* Each WikiPage has a reverse index. You can use this feature to group pages by tags.
* A [top-level index](http://127.0.0.1:8000/cgi-bin/wypyplus.py?p=All&q=f) to show every page in the wiki.
* Auto save after 30 minutes of editing.
* AutoSave after 30 minutes of editing.

## Text Formatting
* WikiNames are replaced with internal links.
Expand Down Expand Up @@ -89,6 +91,10 @@ There's no difference between Tags and WikiWords. When you create a new page, th
For example, you can create a page called ToDo, and put the word ToDo to other pages and see references here:
http://127.0.0.1:8000/cgi-bin/wypyplus?p=ToDo&q=f

### How to define and use a tempalte
You can create a template just like any other wiki page. A tempalte name must start with "Tpl" and follow by three characters. WyPyPlus will automatically insert content to a new wiki page when the first three character of the page matche the tempalte.

For example, If you create a template page called TplJan, a new page called Jan23 will load the content from tempalte.

# Source Code

Expand Down

0 comments on commit e5b419f

Please sign in to comment.