Compare commits

..

No commits in common. "master" and "v0.1a" have entirely different histories.

4 changed files with 36 additions and 86 deletions

View File

@ -1,29 +1,9 @@
# -*- coding: utf_8 -*-
import os,hashlib
import os
def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{menu\}",page="\{page\}",langswitch="\{langswitch\}",depth=""):
"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>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@ -38,7 +18,6 @@ def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{me
<link href="{depth}assets/css/custom.css" rel="stylesheet" />
<!-- GOOGLE FONTS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
{script}
</head>
<body>
<div id="wrapper">
@ -82,7 +61,7 @@ def container(pagetitle="#_pagetitle_#",websitename="#_websitename_#",menu="\{me
<!-- CUSTOM SCRIPTS -->
<script src="{depth}assets/js/custom.js"></script>
</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=""):
@ -112,14 +91,14 @@ def content(content="\{content\}",title="\{title\}"):
{content}
</div>
</div>
<hr />
</div></body>""".format(content=content,title=title)
def iframe(list_of_pages):
iframes=""
percent=round(100/len(list_of_pages))
for page in list_of_pages:
pageid=hashlib.sha224(page).hexdigest()
iframes+="""<iframe src={} width='{}%' id='{}' onload='setIframeHeight(this.id);' style="height='600px'" frameborder='0'>Iframes not supported</iframe>""".format(page,percent,pageid)
iframes+="<iframe src={} width='{}%' height='500px'>Iframes not supported</iframe>".format(page,percent)
return iframes
def assets():

View File

@ -14,28 +14,25 @@
=============================================*/
body {
font-family: 'Open Sans', sans-serif;
height: 100%;
}
#wrapper {
width: 100%;
margin-top:50px;
height: 100%;
}
#page-wrapper {
padding: 15px 15px;
min-height: 600px;
vertical-align: top;
background:#F3F3F3;
height: 100%;
}
#page-inner {
width:100%;
margin:10px 20px 10px 0px;
background-color:#fff!important;
padding:10px;
min-height:100%;
min-height:1200px;
}
.text-center {
@ -111,7 +108,7 @@ color:#0000FF;
}
.nav-second-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:before {
@ -227,7 +224,7 @@ border-radius: 0px;
#page-wrapper{
margin: 0 0 0 260px;
padding: 15px 30px;
min-height: 100%;
min-height: 1200px;
}
@ -243,3 +240,5 @@ border-radius: 0px;
}
}

38
test.py
View File

@ -1,45 +1,20 @@
# Copyleft (c) 2016 Cocobug All Rights Reserved.
# -*- coding: utf_8 -*-
import sys,os
import sys
try:
from blessings import Terminal
except:
print ("Usage of blessings is recomended to run the test")
class Nope(object):
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()
print ("You need to have blessings installed to run the test")
sys.exit()
try:
from minitest import minitest
except:
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 (" you can download it manually at https://github.com/Malphaet/minitest")
print ("the latest version of minitest should have been included with the vkyweb package")
sys.exit()
import types
try:
import markdown
except:
print ("You need markdown installed to parse the files")
sys.exit()
from generator import *
term=Terminal()
@ -380,11 +355,12 @@ class testDual(simple):
self.addFailure(" (got {})".format(dual_select))
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>"""):
self.addFailure("iframes generation incorrect (got {})".format(dual.iframe(["page1.html","page2.html"])))
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")
else:
self.addSuccess()
import os
self.currentTest("dual:pathAssets")
if os.path.exists(dual.assets()):
self.addSuccess()

View File

@ -31,11 +31,8 @@ def iFrameFromNode(node):
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
# TODO: look for index in all nodes, create it if needed
for current_node in tree.get_next_nodes(lang):
shortName=os.path.basename(current_node.name)
if (shortName[0]!="_"): #Likely add a visible: true/false tag in the future
if (os.path.basename(current_node.name)[0]!="_"): #Likely add a visible: true/false tag in the future
filename=htmlNamer[lang](current_node.name)
if args.verbose:
print("Generating {} menus".format(filename))
@ -43,7 +40,7 @@ def gen_all_nodes_menu(tree,lang,previous_node,depth):
list_of_lang=[]
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)
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)
saveData(save,page)
depth="../"+depth
for new in tree.get_next_subtree(lang):
previous_node=new