diff --git a/README.md b/README.md index 4c5ef39..4dec6bb 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/rikiki/README.md b/rikiki/README.md new file mode 100644 index 0000000..1ff3648 --- /dev/null +++ b/rikiki/README.md @@ -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 diff --git a/rikiki/rikiki.py b/rikiki/rikiki.py new file mode 100755 index 0000000..2f98eb8 --- /dev/null +++ b/rikiki/rikiki.py @@ -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"\1";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","

",h,r.M);j.dump(l,o("b","w"));print('Content-Type: text/html\n\n%s

'%(h,c));[n==p and print(r.sub(k,v,m)) for m in l for n in l[m]] \ No newline at end of file