Fixes to local-manual script Part 3.
Added media wiki background, fixed footer, handled mute/unmute special case (it creates a subdirectory), removed "Navigation menu", deployed files from script directory.
@ -8,6 +8,13 @@
|
|||||||
** Michael Zeltner and Geir Bækholt)
|
** Michael Zeltner and Geir Bækholt)
|
||||||
** All you guys rock :)
|
** All you guys rock :)
|
||||||
*/
|
*/
|
||||||
|
body {
|
||||||
|
font: x-small sans-serif;
|
||||||
|
background: #f9f9f9 url(../headbg.jpg) 0 0 no-repeat;
|
||||||
|
color: black;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
#column-content {
|
#column-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
BIN
scripts/mw2html_audacity/audio.png
Normal file
After Width: | Height: | Size: 312 B |
BIN
scripts/mw2html_audacity/bullet.gif
Normal file
After Width: | Height: | Size: 50 B |
BIN
scripts/mw2html_audacity/external.png
Normal file
After Width: | Height: | Size: 165 B |
BIN
scripts/mw2html_audacity/external_rtl.png
Normal file
After Width: | Height: | Size: 198 B |
BIN
scripts/mw2html_audacity/headbg.jpg
Normal file
After Width: | Height: | Size: 7.7 KiB |
@ -196,7 +196,6 @@ def monobook_fix_html(doc, page_url):
|
|||||||
|
|
||||||
# Obselete substitutions.
|
# Obselete substitutions.
|
||||||
# doc = remove_tag(doc, '<div class="portlet" id="p-editors">', '</div>', '<div')
|
# doc = remove_tag(doc, '<div class="portlet" id="p-editors">', '</div>', '<div')
|
||||||
# doc = remove_tag(doc, '<div id=\'catlinks\' class=\'catlinks catlinks-allhidden\'>', '</div>', '<div')
|
|
||||||
#James also remove the page/discussion/source/history/ div.
|
#James also remove the page/discussion/source/history/ div.
|
||||||
doc = remove_tag(doc, '<li id="ca-', '</li>', '<li')
|
doc = remove_tag(doc, '<li id="ca-', '</li>', '<li')
|
||||||
doc = remove_tag(doc, '<div id="p-search" class="portlet"', '</div>', '<div')
|
doc = remove_tag(doc, '<div id="p-search" class="portlet"', '</div>', '<div')
|
||||||
@ -206,6 +205,7 @@ def monobook_fix_html(doc, page_url):
|
|||||||
doc = remove_tag(doc, '<div class="generated-sidebar portlet" id="p-For_Editors"', '</div>', '<div')
|
doc = remove_tag(doc, '<div class="generated-sidebar portlet" id="p-For_Editors"', '</div>', '<div')
|
||||||
doc = remove_tag(doc, '<div class="generated-sidebar portlet" id="p-ToDo"', '</div>', '<div')
|
doc = remove_tag(doc, '<div class="generated-sidebar portlet" id="p-ToDo"', '</div>', '<div')
|
||||||
doc = remove_tag(doc, '<div class="portlet" id="p-tb"', '</div>', '<div')
|
doc = remove_tag(doc, '<div class="portlet" id="p-tb"', '</div>', '<div')
|
||||||
|
doc = remove_tag(doc, '<div id="catlinks"', '</div>', '<div')
|
||||||
#remove javascript.
|
#remove javascript.
|
||||||
doc = remove_tag(doc, '<script', '</script>', '<script')
|
doc = remove_tag(doc, '<script', '</script>', '<script')
|
||||||
|
|
||||||
@ -245,6 +245,8 @@ def monobook_fix_html(doc, page_url):
|
|||||||
# Remove edit links
|
# Remove edit links
|
||||||
doc = remove_tag(doc, '<div class="editsection"', '</div>', '<div')
|
doc = remove_tag(doc, '<div class="editsection"', '</div>', '<div')
|
||||||
doc = remove_tag(doc, '<span class="editsection"', '</span>', '<span')
|
doc = remove_tag(doc, '<span class="editsection"', '</span>', '<span')
|
||||||
|
doc = re.sub(r'<h2>Navigation menu</h2>', r'', doc)
|
||||||
|
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
@ -299,16 +301,24 @@ def pos_html_transform(doc, url,filename):
|
|||||||
|
|
||||||
# Add back relevant stylesheet.
|
# Add back relevant stylesheet.
|
||||||
top_level_dir = config.outdir
|
top_level_dir = config.outdir
|
||||||
if( os.path.dirname(os.path.dirname( filename )) == config.outdir ):
|
if (os.path.dirname(os.path.dirname(filename)) == config.outdir):
|
||||||
doc = re.sub(r'</head>', '<link rel="stylesheet" href="m/skins/monobook/main.css/303.css" media="screen" />\n</head>', doc, flags=re.DOTALL)
|
doc = re.sub(r'</head>',
|
||||||
|
'<link rel="stylesheet" href="m/skins/monobook/main.css/303.css" media="screen" />\n</head>', doc,
|
||||||
|
flags=re.DOTALL)
|
||||||
|
elif (os.path.dirname(os.path.dirname(os.path.dirname(filename))) == config.outdir):
|
||||||
|
doc = re.sub(r'</head>',
|
||||||
|
'<link rel="stylesheet" href="../m/skins/monobook/main.css/303.css" media="screen" />\n</head>',
|
||||||
|
doc,
|
||||||
|
flags=re.DOTALL)
|
||||||
else:
|
else:
|
||||||
doc = re.sub(r'</head>',
|
doc = re.sub(r'</head>',
|
||||||
'<link rel="stylesheet" href="../m/skins/monobook/main.css/303.css" media="screen" />\n</head>', doc,
|
'<link rel="stylesheet" href="../../m/skins/monobook/main.css/303.css" media="screen" />\n</head>',
|
||||||
flags=re.DOTALL)
|
doc,
|
||||||
|
flags=re.DOTALL)
|
||||||
|
|
||||||
# Replace remaining text with footer, if available (this needs to be done after parse_html to avoid rewriting of urls
|
# Replace remaining text with footer, if available (this needs to be done after parse_html to avoid rewriting of urls
|
||||||
if config.footer is not None:
|
if config.footer is not None:
|
||||||
s1 = '<div id="footer">'
|
s1 = '<div id="footer"'
|
||||||
|
|
||||||
# match correct divs
|
# match correct divs
|
||||||
(i1, i2) = find_tag_limits(doc, s1, '</div>', '<div')
|
(i1, i2) = find_tag_limits(doc, s1, '</div>', '<div')
|
||||||
@ -684,7 +694,7 @@ def url_to_filename(url):
|
|||||||
|
|
||||||
#don't sanitize / for path
|
#don't sanitize / for path
|
||||||
L[0] = ''
|
L[0] = ''
|
||||||
L[2] = urllib.quote_plus(L[2], '/')
|
L[2] = urllib.quote_plus(L[2],'/')
|
||||||
L[3] = urllib.quote_plus(L[3])
|
L[3] = urllib.quote_plus(L[3])
|
||||||
L[4] = urllib.quote_plus(L[4])
|
L[4] = urllib.quote_plus(L[4])
|
||||||
L[5] = urllib.quote_plus(L[5])
|
L[5] = urllib.quote_plus(L[5])
|
||||||
@ -905,7 +915,7 @@ def parse_html(doc, url, filename):
|
|||||||
# more pages.
|
# more pages.
|
||||||
for item in L:
|
for item in L:
|
||||||
u = item.url
|
u = item.url
|
||||||
follow = should_follow(u) # and (counter < 10)
|
follow = should_follow(u) #and (counter < 10)
|
||||||
if follow:
|
if follow:
|
||||||
if config.debug:
|
if config.debug:
|
||||||
print 'ACCEPTED - ', u
|
print 'ACCEPTED - ', u
|
||||||
@ -927,6 +937,17 @@ def parse_html(doc, url, filename):
|
|||||||
|
|
||||||
return (newdoc, new_urls)
|
return (newdoc, new_urls)
|
||||||
|
|
||||||
|
def deploy_file( src, dest ):
|
||||||
|
src_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
src = os.path.join(src_dir, src)
|
||||||
|
dest = os.path.join(config.outdir, dest)
|
||||||
|
print "copying from", src, "to", dest
|
||||||
|
directory = os.path.dirname(dest)
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
os.makedirs(directory)
|
||||||
|
copyfile(src,dest)
|
||||||
|
|
||||||
|
|
||||||
def run(out=sys.stdout):
|
def run(out=sys.stdout):
|
||||||
"""
|
"""
|
||||||
Code interface.
|
Code interface.
|
||||||
@ -1030,24 +1051,15 @@ def run(out=sys.stdout):
|
|||||||
print counter, "httplib requests done"
|
print counter, "httplib requests done"
|
||||||
print errors, "errors not recovered"
|
print errors, "errors not recovered"
|
||||||
|
|
||||||
|
deploy_file( "AudacityLogo.png", r"alphamanual.audacityteam.org\m\resources\assets\AudacityLogo.png")
|
||||||
src_dir = os.path.dirname(os.path.realpath(__file__))
|
deploy_file( "303.css", r"alphamanual.audacityteam.org\m\skins\monobook\main.css\303.css")
|
||||||
src = os.path.join(src_dir, "AudacityLogo.png")
|
deploy_file( "headbg.jpg", r"alphamanual.audacityteam.org\m\skins\monobook\headbg.jpg")
|
||||||
subfile = r"alphamanual.audacityteam.org\m\resources\assets\AudacityLogo.png"
|
deploy_file( "audio.png", r"alphamanual.audacityteam.org\m\skins\monobook\audio.png")
|
||||||
dest = os.path.join(config.outdir, subfile)
|
deploy_file( "bullet.gif", r"alphamanual.audacityteam.org\m\skins\monobook\bullet.gif")
|
||||||
print "copying from", src, "to", dest
|
deploy_file( "external.png", r"alphamanual.audacityteam.org\m\skins\monobook\external.png")
|
||||||
directory = os.path.dirname(dest)
|
deploy_file( "external_rtl.png", r"alphamanual.audacityteam.org\m\skins\monobook\external_rtl.png")
|
||||||
if not os.path.exists(directory):
|
deploy_file( "user.gif", r"alphamanual.audacityteam.org\m\skins\monobook\user.gif")
|
||||||
os.makedirs(directory)
|
deploy_file( "video.png", r"alphamanual.audacityteam.org\m\skins\monobook\video.png")
|
||||||
copyfile(src,dest)
|
|
||||||
src = os.path.join(src_dir, "303.css")
|
|
||||||
subfile = r"alphamanual.audacityteam.org\m\skins\monobook\main.css\303.css"
|
|
||||||
dest = os.path.join(config.outdir, subfile)
|
|
||||||
print "copying from", src, "to", dest
|
|
||||||
directory = os.path.dirname(dest)
|
|
||||||
if not os.path.exists(directory):
|
|
||||||
os.makedirs(directory)
|
|
||||||
copyfile(src,dest)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BIN
scripts/mw2html_audacity/user.gif
Normal file
After Width: | Height: | Size: 923 B |
BIN
scripts/mw2html_audacity/video.png
Normal file
After Width: | Height: | Size: 215 B |