mirror of https://github.com/Malphaet/vkyweb.git
Compare commits
No commits in common. "master" and "v0.1a" have entirely different histories.
|
|
@ -1,29 +1,9 @@
|
||||||
# -*- coding: utf_8 -*-
|
# -*- coding: utf_8 -*-
|
||||||
|
|
||||||
import os,hashlib
|
import os
|
||||||
|
|
||||||
def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{menu\}",page="\{page\}",langswitch="\{langswitch\}",depth=""):
|
def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{menu\}",page="\{page\}",langswitch="\{langswitch\}",depth=""):
|
||||||
"Return the global appearance of the website"
|
"Return the global appearance of the website"
|
||||||
script="""<script>
|
|
||||||
function setIframeHeight(id) {
|
|
||||||
var ifrm = document.getElementById(id);
|
|
||||||
var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;
|
|
||||||
ifrm.style.visibility = 'hidden';
|
|
||||||
ifrm.style.height = "10px"; // reset to minimal height ...
|
|
||||||
// IE opt. for bing/msn needs a bit added or scrollbar appears
|
|
||||||
ifrm.style.height = getDocHeight( doc ) + 42 + "px";
|
|
||||||
ifrm.style.visibility = 'visible';
|
|
||||||
ifrm.style.verticalAlign='top';
|
|
||||||
}
|
|
||||||
function getDocHeight(doc) {
|
|
||||||
doc = doc || document;
|
|
||||||
// stackoverflow.com/questions/1145850/
|
|
||||||
var body = doc.body, html = doc.documentElement;
|
|
||||||
var height = Math.max( body.scrollHeight, body.offsetHeight,
|
|
||||||
html.clientHeight, html.scrollHeight, html.offsetHeight );
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
</script>"""
|
|
||||||
return """<!DOCTYPE html>
|
return """<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -38,7 +18,6 @@ def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{me
|
||||||
<link href="{depth}assets/css/custom.css" rel="stylesheet" />
|
<link href="{depth}assets/css/custom.css" rel="stylesheet" />
|
||||||
<!-- GOOGLE FONTS-->
|
<!-- GOOGLE FONTS-->
|
||||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
|
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
|
||||||
{script}
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
|
@ -82,7 +61,7 @@ def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{me
|
||||||
<!-- CUSTOM SCRIPTS -->
|
<!-- CUSTOM SCRIPTS -->
|
||||||
<script src="{depth}assets/js/custom.js"></script>
|
<script src="{depth}assets/js/custom.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>""".format(MENU=menu,PAGE=page,websitename=websitename,pagetitle=pagetitle,depth=depth,langs="",langswitch=langswitch,script=script)
|
</html>""".format(MENU=menu,PAGE=page,websitename=websitename,pagetitle=pagetitle,depth=depth,langs="",langswitch=langswitch)
|
||||||
|
|
||||||
|
|
||||||
def menu(previous="",menulist="\{menulist\}",articles="#_articles_#",depth=""):
|
def menu(previous="",menulist="\{menulist\}",articles="#_articles_#",depth=""):
|
||||||
|
|
@ -112,14 +91,14 @@ def content(content="\{content\}",title="\{title\}"):
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<hr />
|
||||||
</div></body>""".format(content=content,title=title)
|
</div></body>""".format(content=content,title=title)
|
||||||
|
|
||||||
def iframe(list_of_pages):
|
def iframe(list_of_pages):
|
||||||
iframes=""
|
iframes=""
|
||||||
percent=round(100/len(list_of_pages))
|
percent=round(100/len(list_of_pages))
|
||||||
for page in list_of_pages:
|
for page in list_of_pages:
|
||||||
pageid=hashlib.sha224(page).hexdigest()
|
iframes+="<iframe src={} width='{}%' height='500px'>Iframes not supported</iframe>".format(page,percent)
|
||||||
iframes+="""<iframe src={} width='{}%' id='{}' onload='setIframeHeight(this.id);' style="height='600px'" frameborder='0'>Iframes not supported</iframe>""".format(page,percent,pageid)
|
|
||||||
return iframes
|
return iframes
|
||||||
|
|
||||||
def assets():
|
def assets():
|
||||||
|
|
|
||||||
|
|
@ -14,28 +14,25 @@
|
||||||
=============================================*/
|
=============================================*/
|
||||||
body {
|
body {
|
||||||
font-family: 'Open Sans', sans-serif;
|
font-family: 'Open Sans', sans-serif;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#wrapper {
|
#wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top:50px;
|
margin-top:50px;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#page-wrapper {
|
#page-wrapper {
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
min-height: 600px;
|
min-height: 600px;
|
||||||
vertical-align: top;
|
|
||||||
background:#F3F3F3;
|
background:#F3F3F3;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
#page-inner {
|
#page-inner {
|
||||||
width:100%;
|
width:100%;
|
||||||
margin:10px 20px 10px 0px;
|
margin:10px 20px 10px 0px;
|
||||||
background-color:#fff!important;
|
background-color:#fff!important;
|
||||||
padding:10px;
|
padding:10px;
|
||||||
min-height:100%;
|
min-height:1200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-center {
|
.text-center {
|
||||||
|
|
@ -111,7 +108,7 @@ color:#0000FF;
|
||||||
}
|
}
|
||||||
.nav-second-level > li:last-child > a:after,
|
.nav-second-level > li:last-child > a:after,
|
||||||
.nav-third-level > li:last-child > a:after {
|
.nav-third-level > li:last-child > a:after {
|
||||||
height:100%;
|
height:50%;
|
||||||
}
|
}
|
||||||
.nav-third-level > li > a:after,
|
.nav-third-level > li > a:after,
|
||||||
.nav-third-level > li > a:before {
|
.nav-third-level > li > a:before {
|
||||||
|
|
@ -227,7 +224,7 @@ border-radius: 0px;
|
||||||
#page-wrapper{
|
#page-wrapper{
|
||||||
margin: 0 0 0 260px;
|
margin: 0 0 0 260px;
|
||||||
padding: 15px 30px;
|
padding: 15px 30px;
|
||||||
min-height: 100%;
|
min-height: 1200px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,3 +240,5 @@ border-radius: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
38
test.py
38
test.py
|
|
@ -1,45 +1,20 @@
|
||||||
# Copyleft (c) 2016 Cocobug All Rights Reserved.
|
# Copyleft (c) 2016 Cocobug All Rights Reserved.
|
||||||
# -*- coding: utf_8 -*-
|
# -*- coding: utf_8 -*-
|
||||||
|
|
||||||
import sys,os
|
import sys
|
||||||
try:
|
try:
|
||||||
from blessings import Terminal
|
from blessings import Terminal
|
||||||
except:
|
except:
|
||||||
print ("Usage of blessings is recomended to run the test")
|
print ("You need to have blessings installed to run the test")
|
||||||
class Nope(object):
|
sys.exit()
|
||||||
def __init__(self,*args,**kwargs):
|
|
||||||
pass
|
|
||||||
def __getattribute__(self,attr):
|
|
||||||
return Nope()
|
|
||||||
def __str__(self):
|
|
||||||
return ""
|
|
||||||
def __call__(self,*args,**kargs):
|
|
||||||
return "".join(args)
|
|
||||||
def __repr__(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
class T(object):
|
|
||||||
def __init__(self,*args,**kwargs):
|
|
||||||
pass
|
|
||||||
def __getattribute__(self,attr):
|
|
||||||
return Nope()
|
|
||||||
Terminal=T
|
|
||||||
#sys.exit()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from minitest import minitest
|
from minitest import minitest
|
||||||
except:
|
except:
|
||||||
print ("You need to have minitest installed to run the test")
|
print ("You need to have minitest installed to run the test")
|
||||||
print (" the latest version of minitest should have been included with the vkyweb package")
|
print ("the latest version of minitest should have been included with the vkyweb package")
|
||||||
print (" you can download it manually at https://github.com/Malphaet/minitest")
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
import types
|
import types
|
||||||
|
|
||||||
try:
|
|
||||||
import markdown
|
|
||||||
except:
|
|
||||||
print ("You need markdown installed to parse the files")
|
|
||||||
sys.exit()
|
|
||||||
from generator import *
|
from generator import *
|
||||||
|
|
||||||
term=Terminal()
|
term=Terminal()
|
||||||
|
|
@ -380,11 +355,12 @@ class testDual(simple):
|
||||||
self.addFailure(" (got {})".format(dual_select))
|
self.addFailure(" (got {})".format(dual_select))
|
||||||
|
|
||||||
self.currentTest("dual:iframe")
|
self.currentTest("dual:iframe")
|
||||||
if (dual.iframe(["page1.html","page2.html"])!="""<iframe src=page1.html width='50.0%' id='a92a4d23fa8021c72774d45b474fbe034fd714cb21e422c499eb7f54' onload='setIframeHeight(this.id);' style="height='600px'" frameborder='0'>Iframes not supported</iframe><iframe src=page2.html width='50.0%' id='2eb2decff6c3e2f20da50e42064669b085057f981e316be8c1890afb' onload='setIframeHeight(this.id);' style="height='600px'" frameborder='0'>Iframes not supported</iframe>"""):
|
if (dual.iframe(["page1.html","page2.html"])!="""<iframe src=page1.html width='50.0%' height='500px'>Iframes not supported</iframe><iframe src=page2.html width='50.0%' height='500px'>Iframes not supported</iframe>"""):
|
||||||
self.addFailure("iframes generation incorrect (got {})".format(dual.iframe(["page1.html","page2.html"])))
|
self.addFailure("iframes generation incorrect")
|
||||||
else:
|
else:
|
||||||
self.addSuccess()
|
self.addSuccess()
|
||||||
|
|
||||||
|
import os
|
||||||
self.currentTest("dual:pathAssets")
|
self.currentTest("dual:pathAssets")
|
||||||
if os.path.exists(dual.assets()):
|
if os.path.exists(dual.assets()):
|
||||||
self.addSuccess()
|
self.addSuccess()
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,8 @@ def iFrameFromNode(node):
|
||||||
def gen_all_nodes_menu(tree,lang,previous_node,depth):
|
def gen_all_nodes_menu(tree,lang,previous_node,depth):
|
||||||
#previous_node=tree.parent_node #maybe need to be sent via parameter, nonetheless very secondary
|
#previous_node=tree.parent_node #maybe need to be sent via parameter, nonetheless very secondary
|
||||||
# TODO: look for index in all nodes, create it if needed
|
# TODO: look for index in all nodes, create it if needed
|
||||||
|
|
||||||
for current_node in tree.get_next_nodes(lang):
|
for current_node in tree.get_next_nodes(lang):
|
||||||
shortName=os.path.basename(current_node.name)
|
if (os.path.basename(current_node.name)[0]!="_"): #Likely add a visible: true/false tag in the future
|
||||||
|
|
||||||
if (shortName[0]!="_"): #Likely add a visible: true/false tag in the future
|
|
||||||
filename=htmlNamer[lang](current_node.name)
|
filename=htmlNamer[lang](current_node.name)
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print("Generating {} menus".format(filename))
|
print("Generating {} menus".format(filename))
|
||||||
|
|
@ -43,7 +40,7 @@ def gen_all_nodes_menu(tree,lang,previous_node,depth):
|
||||||
|
|
||||||
list_of_lang=[]
|
list_of_lang=[]
|
||||||
for l in args.l:
|
for l in args.l:
|
||||||
list_of_lang.append((l,htmlNamer[l](shortName),tree.get_variable(l,lang).capitalize()))
|
list_of_lang.append((l,htmlNamer[l](os.path.basename(current_node.name)),tree.get_variable(l,lang).capitalize()))
|
||||||
|
|
||||||
langswitch=model.makeLangSwitch(choosen_model,list_of_lang,lang)
|
langswitch=model.makeLangSwitch(choosen_model,list_of_lang,lang)
|
||||||
menu=model.makeContainer(choosen_model,website,current_node,previous_node,lang,htmlNamer[lang],depth,langswitch)
|
menu=model.makeContainer(choosen_model,website,current_node,previous_node,lang,htmlNamer[lang],depth,langswitch)
|
||||||
|
|
@ -51,7 +48,6 @@ def gen_all_nodes_menu(tree,lang,previous_node,depth):
|
||||||
page=model.makePage(choosen_model,website,lang,menu,frames,depth,langswitch)
|
page=model.makePage(choosen_model,website,lang,menu,frames,depth,langswitch)
|
||||||
|
|
||||||
saveData(save,page)
|
saveData(save,page)
|
||||||
|
|
||||||
depth="../"+depth
|
depth="../"+depth
|
||||||
for new in tree.get_next_subtree(lang):
|
for new in tree.get_next_subtree(lang):
|
||||||
previous_node=new
|
previous_node=new
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue