Hover effect for galleries done;

Outputs are now W3C compilant - note there is a bug in certain versions
of the markdown libary it generates `rel` and `rev` attributes for the
`<a>`-tags, which is illegal since HTML5. I've informed the developer
so using the newest version you can get would fix it. Otherwise find and
comment the following two lines:

	a.set('rel', 'footnote')
    backlink.set("rev", "footnote")

in `examples/footnotes.py` of the library
master
Stefan Krulj 14 years ago
parent ee3a034837
commit 628af85510
  1. 24
      gallery.js
  2. 15
      mdx_gallery.py
  3. 3
      pylog.py
  4. 10
      pylog_action_impl.py
  5. 3
      pylog_config.py
  6. 80
      style.css

@ -1,5 +1,5 @@
var current_li; var current_anch;
function nextByTag(parent,current,name){ function nextByTag(parent,current,name){
var next = false; var next = false;
@ -34,12 +34,12 @@ function prevByTag(parent,current,name){
} }
function prevImg(){ function prevImg(){
var parent = current_li.parentNode; var parent = current_anch.parentNode;
var prev_li = prevByTag(parent,current_li,"LI"); var next_anch = prevByTag(parent,current_anch,"A");
if( !prev_li ){ if( !next_anch ){
return false; return false;
} }
var img = prev_li.getElementsByTagName("img")[0]; var img = next_anch.getElementsByTagName("img")[0];
var div = document.getElementById("gallery_container"); var div = document.getElementById("gallery_container");
var oldimg = div.getElementsByTagName("img"); var oldimg = div.getElementsByTagName("img");
if( oldimg ){ if( oldimg ){
@ -49,17 +49,17 @@ function prevImg(){
} }
} }
} }
current_li = prev_li; current_anch = next_anch;
return false; return false;
} }
function nextImg(){ function nextImg(){
var parent = current_li.parentNode; var parent = current_anch.parentNode;
var next_li = nextByTag(parent,current_li,"LI"); var next_anch = nextByTag(parent,current_anch,"A");
if( !next_li ){ if( !next_anch ){
return false; return false;
} }
var img = next_li.getElementsByTagName("img")[0]; var img = next_anch.getElementsByTagName("img")[0];
var div = document.getElementById("gallery_container"); var div = document.getElementById("gallery_container");
var oldimg = div.getElementsByTagName("img"); var oldimg = div.getElementsByTagName("img");
if( oldimg ){ if( oldimg ){
@ -69,14 +69,14 @@ function nextImg(){
} }
} }
} }
current_li = next_li; current_anch = next_anch;
return false; return false;
} }
function loadImg(src,target){ function loadImg(src,target){
var body = document.getElementsByTagName("body")[0]; var body = document.getElementsByTagName("body")[0];
var div = document.getElementById("gallery_container"); var div = document.getElementById("gallery_container");
current_li = target.parentNode; current_anch = target;
if( !div ) { if( !div ) {
div = document.createElement('div'); div = document.createElement('div');

@ -6,29 +6,28 @@ import markdown, urllib
class GalleryPattern(Pattern): class GalleryPattern(Pattern):
def __init__(self,md): def __init__(self,md):
Pattern.__init__(self,'!\\[(.*?)\\]\(\((.*?)\)\)',md) # Pattern.__init__(self,'!\\[(.*?)\\]\(\((.*?)\)\)',md) # ![alt]((img1 img2 ... imgn))
def handleMatch(self, m): def handleMatch(self, m):
alt=m.group(2) alt=m.group(2)
imgs=m.group(3).split() imgs=m.group(3).split()
ul = markdown.util.etree.Element('ul') span = markdown.util.etree.Element('span')
ul.attrib["class"]='gallery' span.attrib["class"]='gallery'
for img in imgs: for img in imgs:
li = markdown.util.etree.Element('li')
ul.append(li)
anch = markdown.util.etree.Element('a') anch = markdown.util.etree.Element('a')
anch.attrib["href"]=img anch.attrib["href"]=img
anch.attrib["target"]="_blank" anch.attrib["target"]="_blank"
anch.attrib["class"]="gallery_link"
anch.attrib["onclick"]='loadImg("%s",this);return false;' % (img) anch.attrib["onclick"]='loadImg("%s",this);return false;' % (img)
li.append(anch) span.append(anch)
img_el = markdown.util.etree.Element('img') img_el = markdown.util.etree.Element('img')
anch.append(img_el)
img_el.attrib["src"]=img img_el.attrib["src"]=img
img_el.attrib["alt"]=alt img_el.attrib["alt"]=alt
anch.append(img_el)
return ul return span
class GalleryExtension(markdown.Extension): class GalleryExtension(markdown.Extension):
def extendMarkdown(self, md, md_globals): def extendMarkdown(self, md, md_globals):

@ -111,7 +111,7 @@ def disp_file_dict(d,keys):
name = os.path.basename(f) name = os.path.basename(f)
if typ in prev_actions and not os.path.isdir(f): if typ in prev_actions and not os.path.isdir(f):
sys.stdout.write('<h1><a class="entryheader" href="'+script+'?') sys.stdout.write('<h1><a class="entryheader" href="'+script+'?')
sys.stdout.write('disp='+os.path.normpath(f)+'">') sys.stdout.write('disp='+os.path.normpath(f).replace(' ','+')+'">')
print name+'</a> - <span class="entrydate">', print name+'</a> - <span class="entrydate">',
print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt), print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt),
print '</span>&nbsp;' print '</span>&nbsp;'
@ -284,6 +284,7 @@ try:
print '<hr>' print '<hr>'
print '<div id="footer">' print '<div id="footer">'
print cfg.footer print cfg.footer
print '</div>'
comment_section.disp_comments(validdisp) comment_section.disp_comments(validdisp)
else: else:
disp_list(path) disp_list(path)

@ -24,7 +24,7 @@ def dir_link(name,f,depth,hidden):
if hidden: if hidden:
print ' hidden', print ' hidden',
print '">' print '">'
print ' <a class="menulink" href="'+script+'?'+'path='+os.path.normpath(f)+'">'+name+'</a>' print ' <a class="menulink" href="'+script+'?'+'path='+os.path.normpath(f).replace(' ','+')+'">'+name+'</a>'
print ' </li>' print ' </li>'
def file_link(name,f,depth,hidden): def file_link(name,f,depth,hidden):
script = sys.argv[0][sys.argv[0].rindex('/')+1:] script = sys.argv[0][sys.argv[0].rindex('/')+1:]
@ -32,14 +32,14 @@ def file_link(name,f,depth,hidden):
if hidden: if hidden:
print ' hidden', print ' hidden',
print '">' print '">'
print ' <a class="menulink" href="'+script+'?'+'disp='+os.path.normpath(f)+'">'+name+'</a>' print ' <a class="menulink" href="'+script+'?'+'disp='+os.path.normpath(f).replace(' ','+')+'">'+name+'</a>'
print ' </li>' print ' </li>'
def disp_txt(path): def disp_txt(path):
print '<div class="entrytext">' print '<div class="entrytext">'
f = codecs.open(path, mode="r", encoding=cfg.encoding) f = codecs.open(path, mode="r", encoding=cfg.encoding)
txt=f.read() txt=f.read()
print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) print markdown.markdown(txt,extensions=cfg.markdown_extensions,content_format=cfg.content_format).encode(cfg.encoding)
f.close() f.close()
print '</div>' print '</div>'
@ -58,7 +58,7 @@ def disp_source(path,lang,line_numbers):
txt="\t:::"+lang+'\n' txt="\t:::"+lang+'\n'
for line in f.read().split('\n'): for line in f.read().split('\n'):
txt += "\t"+line+'\n' txt += "\t"+line+'\n'
print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) print markdown.markdown(txt,extensions=cfg.markdown_extensions,content_format=cfg.content_format).encode(cfg.encoding)
f.close() f.close()
print '</div>' print '</div>'
@ -99,7 +99,7 @@ def prev(path):
def prev_txt(path): def prev_txt(path):
fi = codecs.open(path, mode="r", encoding=cfg.encoding) fi = codecs.open(path, mode="r", encoding=cfg.encoding)
txt=get_n_words(fi,40) txt=get_n_words(fi,40)
print '<div class="preview">'+markdown.markdown(txt[0],extensions=cfg.markdown_extensions).encode(cfg.encoding) print '<div class="preview">'+markdown.markdown(txt[0],extensions=cfg.markdown_extensions, content_format=cfg.content_format).encode(cfg.encoding)
if txt[1]: if txt[1]:
print '<i>&nbsp;...</i>' print '<i>&nbsp;...</i>'
print '</div>' print '</div>'

@ -38,6 +38,9 @@ encoding="utf-8"
# format. See manual reference for codecs.open for # format. See manual reference for codecs.open for
# details # details
content_format="html5"
# The content-format generated by the markdown-library
markdown_extensions = ['math','gallery','extra','codehilite(guess_lang=False)',] markdown_extensions = ['math','gallery','extra','codehilite(guess_lang=False)',]
# Markdown extensions: # Markdown extensions:
# math .......... rich subset of latex formulas between $$ c^2=a^2+b^2 $$ # math .......... rich subset of latex formulas between $$ c^2=a^2+b^2 $$

@ -274,43 +274,71 @@ span.pre {
font-family:monospace; font-family:monospace;
} }
ul.gallery { .gallery_link{
display:block; transform: rotate(1deg);
display:inline-block;
padding:0px; padding:0px;
height:90px; -moz-transition: all 0.5s;
} -webkit-transition: all 0.5s;
ul.gallery li { -ms-transition: all 0.5s;
display:inline; -o-transition: all 0.5s;
transition: all 0.5s
} }
.gallery_link:nth-child(2n+1) {
transform: rotate(3deg);
-ms-transform: rotate(3deg);
-webkit-transform: rotate(3deg);
-o-transform: rotate(3deg);
-moz-transform: rotate(3deg);
}
.gallery_link:nth-child(3n+1) {
transform: rotate(-7deg);
-ms-transform: rotate(-7deg);
-webkit-transform: rotate(-7deg);
-o-transform: rotate(-7deg);
-moz-transform: rotate(-7deg);
}
.gallery_link:nth-child(7n+1) {
transform: rotate(-4deg);
-ms-transform: rotate(-4deg);
-webkit-transform: rotate(-4deg);
-o-transform: rotate(-4deg);
-moz-transform: rotate(-4deg);
}
.gallery_link:nth-child(5n+1) {
transform: rotate(-2deg);
-ms-transform: rotate(-2deg);
-webkit-transform: rotate(-2deg);
-o-transform: rotate(-2deg);
-moz-transform: rotate(-2deg);
}
.gallery_link:hover {
transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
-moz-transform: rotate(0deg);
}
ul.gallery li img{ .gallery_link img{
/*transform: rotate(2deg);*/
border:2px solid white; border:2px solid white;
box-shadow: 0px 1px 4px black; box-shadow: 0px 1px 4px black;
-webkit-box-shadow: 0px 3px 12px #444444;
-moz-box-shadow: 0px 3px 12px #444444;
height:75px; height:75px;
margin:4px; margin:4px;
-moz-transition: all 0.5s; -moz-transition: all 0.5s;
-webkit-transition: all 0.5s; -webkit-transition: all 0.5s;
-ms-transition: all 0.5s; -ms-transition: all 0.5s;
-o-transition: all 0.5s; -o-transition: all 0.5s;
transition: all 0.5s transition: all 0.5s
} }
ul.gallery li img:nth-of-type(even) {
transform: rotate(1deg); .gallery_link img:hover{
}
ul.gallery li img:nth-of-type(odd) {
transform: rotate(-2deg);
}
/*ul.gallery li img:img:nth-of-type(5n) {
transform: rotate(3deg);
}
ul.gallery li img:img:nth-of-type(7n) {
transform: rotate(-1deg);
}*/
ul.gallery li img:hover{
transform: rotate(0deg);
box-shadow: 0px 1px 6px black; box-shadow: 0px 1px 6px black;
-webkit-box-shadow: 0px 3px 12px #444444;
-moz-box-shadow: 0px 3px 12px #444444;
height:82px; height:82px;
margin:0px; margin:0px;
} }

Loading…
Cancel
Save