summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/myhtml.py (renamed from scripts/html.py)46
1 files changed, 45 insertions, 1 deletions
diff --git a/scripts/html.py b/scripts/myhtml.py
index 07727d0..d395cb8 100755
--- a/scripts/html.py
+++ b/scripts/myhtml.py
@@ -5,6 +5,7 @@
#
# 2019/02/18 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
#===============================
+import textile
import sys
import os
import re
@@ -13,7 +14,6 @@ import base
import find
import view
import datetime
-
#====================================
#
# html
@@ -257,6 +257,13 @@ class periject_html(base.base):
self.__summary(dir, self.top() + "/" + dir, find.find([dir]).get())
#--------------------
+ # menu_wiki
+ #--------------------
+ def menu_wiki(self):
+ html("a", {"target":"_blank",
+ "href":"./wiki/top.html"}).print("Peri Peri Wiki")
+
+ #--------------------
# menu_folder
#--------------------
def menu_folder(self, current):
@@ -319,6 +326,9 @@ class periject_html(base.base):
def menu(self):
with html("body"):
+ html("h1").print("Wiki")
+ self.menu_wiki()
+
html("h1").print("Folder")
with html("ul"):
self.menu_folder("./projects")
@@ -339,6 +349,38 @@ class periject_html(base.base):
datetime.datetime.now().strftime("%Y/%m/%d %H:%M")))
#--------------------
+ # wiki
+ #--------------------
+ def wiki(self, argv):
+
+ with open(argv[0], "r") as f:
+ text = f.read()
+
+ # parse http[s]
+ text = re.sub(r'(\s+)http://(.*)(\s+)', r'\1"http://\2":http://\2\3', text)
+ text = re.sub(r'(\s+)https://(.*)(\s+)', r'\1"https://\2":https://\2\3', text)
+
+ # parse img
+ text = re.sub(r'!(\S+)!', r'!../../wiki/\1!', text)
+
+ # [[foo bar]]
+ # -> "foo bar":foo_bar.html
+ while 1:
+ hit = re.search(r'\[\[.*\]\]', text)
+
+ if (not hit):
+ break;
+
+ link = text[hit.start()+2:hit.end()-2]
+ link = "\"{}\":{}.html".format(link, re.sub(r' ', r'_', link))
+
+ text = text[:hit.start()] + link + text[hit.end():]
+
+ # textile
+ print("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../wiki/css\">")
+ print(textile.textile(text))
+
+ #--------------------
# body
#--------------------
def body(self):
@@ -657,6 +699,8 @@ class periject_html(base.base):
elif (cmd == "bsp"):
# ./script/find.py -a | xargs ./script/html.py bsp
self.bsp(sys.argv)
+ elif (cmd == "wiki"):
+ self.wiki(sys.argv)
#====================================
#