Added rikiki
This commit is contained in:
parent
704503d6e0
commit
deb0362407
|
@ -15,3 +15,7 @@ the range of the month.
|
|||
|
||||
Plus, source code has been tweaked to be seen as a rabbit in ASCII art.
|
||||
|
||||
|
||||
## rikiki
|
||||
|
||||
Smallest Wiki in python3 ? Maybe, but I got more work to do on it.
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
Rikiki is a small Wiki engine in python3 I built for [Shortest Wiki Contest](http://wiki.c2.com/?ShortestWikiContest).
|
||||
|
||||
Rikiki means "tiny" in french.
|
||||
|
||||
Fun fact: Rikiki source code is *three times smaller* than this readme file.
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
**YOU SHALL NOT USE THIS CODE IN PRODUCTION!**
|
||||
|
||||
This code is **NOT SECURE** and it is based onto CGI technology which is **OBSOLETE** for production.
|
||||
|
||||
To run this wiki, you need python3 only :
|
||||
|
||||
1. Create a folder named "wiki"
|
||||
2. Create a sub-folder named "cgi-bin"
|
||||
3. Copy rikiki.py inside the "cgi-bin" folder
|
||||
4. Run this command from the wiki folder :
|
||||
PYTHONWARNINGS="ignore" python -m http.server --cgi
|
||||
|
||||
Now, you can go and visit : http://localhost:8000/cgi-bin/rikiki.py?p=HomePage
|
||||
|
||||
|
||||
# Features
|
||||
|
||||
As stated in the Shortest Wiki Contest consraints,there are some [Wiki Principles](http://wiki.c2.com/?WikiPrinciples)
|
||||
to obey :
|
||||
|
||||
* Automatic Link Generation: Each page is in CamelCase. As soon as you write it in source, it is available via a link.
|
||||
* Content Editable By All: Totally open, **everyone** can change sources and create more pages.
|
||||
* EasyTextInput: Paragraphs are done with breaking lines, link to other pages are done in CamelCase.
|
||||
* Back Links: If a page A links to a page B, this page B will display a link to page A.
|
||||
|
||||
|
||||
## Constraints
|
||||
|
||||
In order to gain bytes, you can't do a lot :
|
||||
|
||||
* Only ASCII characters are managed
|
||||
* Formating text is *highly* limited ;o)
|
||||
* Input textarea should be resized before typing
|
||||
* No versioning of sources
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env python3
|
||||
import cgi,json as j,re as r;p,s,c=map(cgi.parse().get,"psc");p,o=p[0],open;s and o(p,"w").write(s[0]);o(p,"a");o("b","a");l,k,v=j.loads(o("b").read()or"{}"),r"(([A-Z][\w]+){2})",r"<a href=?p=\1>\1</a>";c=s[0] if s else o(p).read();l[p]=[x[0] for x in r.findall(k,c)];h=r.sub(k,v,c,r.M);h=r.sub(r"\n","<p>",h,r.M);j.dump(l,o("b","w"));print('Content-Type: text/html\n\n%s<form method=POST><textarea name=s>%s</textarea><input type=submit></form>'%(h,c));[n==p and print(r.sub(k,v,m)) for m in l for n in l[m]]
|
Loading…
Reference in New Issue