summaryrefslogtreecommitdiff
path: root/helpcontent2
diff options
context:
space:
mode:
authorTimo Richter <timo@iera.de>2011-08-08 20:47:22 +0200
committerJan Holesovsky <kendy@suse.cz>2011-08-26 13:48:13 +0200
commit96210e715d167f793ce8830b4152f3327c265552 (patch)
tree00279934a87df0b0e91997004399c7ce0850976e /helpcontent2
parent4d674531da66d668ff5b6292da849d07d315c60d (diff)
Bugfixes for mwlib
Images can be displayed. Use --images and a relative path.
Diffstat (limited to 'helpcontent2')
-rw-r--r--helpcontent2/wiki-to-help/README2
-rwxr-xr-xhelpcontent2/wiki-to-help/convert.py22
-rw-r--r--helpcontent2/wiki-to-help/metabook.json6
-rw-r--r--helpcontent2/wiki-to-help/metabook_translated.py7
-rw-r--r--helpcontent2/wiki-to-help/mwlib_mods/__init__.py5
-rw-r--r--helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py1
-rw-r--r--helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py55
-rw-r--r--helpcontent2/wiki-to-help/test2.xml58
8 files changed, 146 insertions, 10 deletions
diff --git a/helpcontent2/wiki-to-help/README b/helpcontent2/wiki-to-help/README
index 1eb3e442c5..f384debb20 100644
--- a/helpcontent2/wiki-to-help/README
+++ b/helpcontent2/wiki-to-help/README
@@ -21,6 +21,8 @@ The following programs are required:
2 USAGE
+See ./convert.py -h
+
3 LICENSE
The following applies to all files if not stated differently
diff --git a/helpcontent2/wiki-to-help/convert.py b/helpcontent2/wiki-to-help/convert.py
index 2bbc82e944..dd0c0a597a 100755
--- a/helpcontent2/wiki-to-help/convert.py
+++ b/helpcontent2/wiki-to-help/convert.py
@@ -27,9 +27,10 @@ class Main(object):
''' Defines program parameters and returns them as a dictionary '''
def parseArgs(self):
parser = argparse.ArgumentParser(description='Conversion from a mediawiki xml-dumpfile to helpfiles')
- parser.add_argument("--startpage", metavar="Path", dest="startpage", default=None, type=str, help="Sets a HTML-file as the start page")
+ parser.add_argument("--startpage", metavar="PATH", dest="startpage", default=None, type=str, help="Sets a HTML-file as the start page")
+ parser.add_argument("--images", metavar="PATH", dest="imgPath", default=None, type=str, help="Uses images from PATH")
parser.add_argument("--keep", dest="keepTmp", default=False, action='store_true', help="Keeps temporary files in /tmp")
- parser.add_argument("--only-en", dest="onlyEn", action='store_true', default=False, help="Convert only English articles")
+ parser.add_argument("--only-en", dest="onlyEn", action='store_true', default=False, help="Converts only English articles")
parser.add_argument("--no-chm", dest="createChm", default=True, action='store_false', help="Avoids creation of a CHM file at the end")
parser.add_argument("input", type=str, help="XML input")
parser.add_argument("output", type=str, help="Directory for output")
@@ -45,6 +46,7 @@ class Main(object):
dest=args.output,
startpage=args.startpage,
onlyEn=args.onlyEn,
+ imgPath=args.imgPath,
)()
exit(int(not r))
@@ -52,7 +54,6 @@ class Main(object):
class Converter(object):
createChm = None #
keepTmp = None #
- #workingDir = "./test" # final
#style=os.path.join(scriptpath,'xsl/htmlhelp/htmlhelp.xsl') # final
style=os.path.join(scriptpath,'htmlhelp.xsl') # final
title="LibreOffice" # final
@@ -69,11 +70,10 @@ class Converter(object):
print cmd
return (subprocess.Popen(cmd).wait() == 0)
- def __init__(self,source,dest,onlyEn,keepTmp=False,createChm=True,startpage=None):
+ def __init__(self,source,dest,onlyEn,imgPath,
+ keepTmp=False,createChm=True,startpage=None):
"""
- @source XML-Dump-file
- @dest Directory for output
- @startpage Path to an html file
+ Parameters are documented in Main.parseArgs()
"""
self.createChm = createChm
self.keepTmp=keepTmp
@@ -88,6 +88,11 @@ class Converter(object):
self.dest=dest
self.startpage=startpage
self.onlyEn = onlyEn
+ if imgPath:
+ self.imgPath = os.path.join(imgPath,"IMAGENAME")
+ else:
+ self.imgPath = "IMAGENAME"
+
def createDir(self,path):
try:
@@ -126,7 +131,8 @@ class Converter(object):
docbookfile = os.path.join(tmp,"docbook_%s.xml"%lang)
chmDest = os.path.join(self.dest,lang+".chm")
- MW.render("--config=%s/wikiconf.txt"%(tmp),
+ MW.render("-L",lang,"-W","imagesrcresolver=%s"%self.imgPath,
+ "--config=%s/wikiconf.txt"%(tmp),
"-w","docbook","-o",docbookfile,"-m",metabook,"--title",self.title)
shutil.copy(docbookfile,self.dest)
if not self.ex("/usr/bin/xsltproc","--nonet","--novalid","-o",tmp+'/',self.style,docbookfile): return False
diff --git a/helpcontent2/wiki-to-help/metabook.json b/helpcontent2/wiki-to-help/metabook.json
index 76814b6a2d..4f460a1e40 100644
--- a/helpcontent2/wiki-to-help/metabook.json
+++ b/helpcontent2/wiki-to-help/metabook.json
@@ -18,5 +18,9 @@
"type": "wikiconf",
"ident": "en"
}
- ]
+ ],
+ "images(deprecated)": {
+ "movedata.png": {"url": "http://path/movedata.png"}
+
+ }
}
diff --git a/helpcontent2/wiki-to-help/metabook_translated.py b/helpcontent2/wiki-to-help/metabook_translated.py
index e9321c2fa5..a7f90dbcd1 100644
--- a/helpcontent2/wiki-to-help/metabook_translated.py
+++ b/helpcontent2/wiki-to-help/metabook_translated.py
@@ -39,6 +39,7 @@ class ArticleTranslated(metabook.Article):
class MetabookTranslated(metabook.Metabook):
"""
+ This metabook contains all articles with translated titles.
This concrete metabook expects article titles in this form:
Category/Title/lang
Comments include this:
@@ -63,7 +64,7 @@ class LanguageSeparator(object):
def splitItemsByLanguage(self):
"""
- @return List of Metabook
+ Sort the articles in self.items by language and put them to self.sortedItems
"""
sortedItems={}
for item in self.items:
@@ -75,6 +76,10 @@ class LanguageSeparator(object):
#return sortedItems
def createBooksByLanguage(self):
+ """
+ Generate metabooks to self.books.
+ Create a metabook for each language from self.sortedItems.
+ """
for lang, items in self.sortedItems.iteritems():
m = self.book.getClone()
m.items = items
diff --git a/helpcontent2/wiki-to-help/mwlib_mods/__init__.py b/helpcontent2/wiki-to-help/mwlib_mods/__init__.py
index 381f31211e..c9c59e96f9 100644
--- a/helpcontent2/wiki-to-help/mwlib_mods/__init__.py
+++ b/helpcontent2/wiki-to-help/mwlib_mods/__init__.py
@@ -5,6 +5,9 @@ Usage: import mwlib_mods
# The order of the imports is relevant!
+import docbookwriter_options
+docbookwriter_options.apply()
+
import no_sections
no_sections.apply()
@@ -14,4 +17,6 @@ docbook_internLinks.apply()
import custom_nfo
custom_nfo.apply()
+#import images_from_path
+#images_from_path.apply()
diff --git a/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py b/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py
index 9c1bb08656..558e2a5a85 100644
--- a/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py
+++ b/helpcontent2/wiki-to-help/mwlib_mods/docbook_internLinks.py
@@ -37,6 +37,7 @@ import lxml.etree
class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter):
def getTargetId(self,title):
""" Transform "The first article" to "The_first_article" """
+ # See mwlib.zipwiki.normalize_title()
return title.replace(" ","_")
def dbwriteArticle(self, a):
diff --git a/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py b/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py
new file mode 100644
index 0000000000..7b11324766
--- /dev/null
+++ b/helpcontent2/wiki-to-help/mwlib_mods/docbookwriter_options.py
@@ -0,0 +1,55 @@
+"""
+This enables -L, --language and -W for docbook output.
+Additionally the magic word IMAGENAME will contain the imagename instead of "IMAGE:imagename"
+
+Example:
+ mw-render -w docbook -L de -W debug=True;imagesrcresolver=/home/images/IMAGENAME
+
+The content of writer() belongs to the mwlib.
+
+"""
+
+from mwlib.docbookwriter import *
+def writer(env, output, status_callback, **args): # changed
+ """ This is the function for external use. It is called by apps.render """
+ if status_callback:
+ buildbook_status = status_callback.getSubRange(0, 50)
+ else:
+ buildbook_status = None
+ book = writerbase.build_book(env, status_callback=buildbook_status)
+ scb = lambda status, progress : status_callback is not None and status_callback(status=status, progress=progress)
+ scb(status='preprocessing', progress=50)
+ for c in book.children:
+ preprocess(c)
+ scb(status='rendering', progress=60)
+
+ args["language"] = args["lang"] # changed
+ del args["lang"] # changed
+ mwlib.docbookwriter.DocBookWriter(env, status_callback=scb, documenttype="book", **args).writeBook(book, output=output) # changed
+
+def setupWriter():
+ mwlib.docbookwriter.writer = writer
+ mwlib.docbookwriter.writer.options = \
+ ["documenttype","lang","imagesrcresolver","debug"]
+
+
+
+import mwlib.docbookwriter
+class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter):
+ def dbwriteImageLink(self, obj):
+ print "Mod:dbwriteImageLink"
+ if obj.target:
+ name = obj.target
+ obj.target = name[name.find(":") + 1:]
+ return super(MyDocBookWriter,self).dbwriteImageLink(obj)
+
+def setupDocBookWriter():
+ mwlib.docbookwriter.DocBookWriter = MyDocBookWriter
+
+
+
+def apply():
+ setupWriter()
+ setupDocBookWriter()
+
+
diff --git a/helpcontent2/wiki-to-help/test2.xml b/helpcontent2/wiki-to-help/test2.xml
index ed355e75bd..6cda28dc08 100644
--- a/helpcontent2/wiki-to-help/test2.xml
+++ b/helpcontent2/wiki-to-help/test2.xml
@@ -428,4 +428,62 @@ Sæt skriftstørrelsen for den markerede tekst.
[[Common/Getting_Support|Getting Support]]</text>
</revision>
</page>
+ <page>
+ <title>Common/Dragging and Dropping Within a Document</title>
+ <id>40966</id>
+ <revision>
+ <id>86420</id>
+ <timestamp>2011-01-19T16:04:35Z</timestamp>
+ <contributor>
+ <username>WikiSysop</username>
+ <id>1</id>
+ </contributor>
+ <text xml:space="preserve">{{OrigLang|Dragging and Dropping Within a {{ProductName}} Document}}
+&lt;div id=&quot;bm_id3154927&quot;&gt;&lt;/div&gt;
+There are many options for moving or copying objects using drag-and-drop. Text sections, drawing objects, graphics, form controls, hyperlinks, cell ranges, and many more can be moved or copied with the mouse.
+
+Note that the mouse pointer displays a plus sign when copying and an arrow when creating a link or hyperlink.
+
+{| border=&quot;1&quot;
+|-
+! scope=&quot;col&quot; | Mouse Pointer
+! scope=&quot;col&quot; | Description
+|-
+| [[Image:movedata.png|border|left|8.47mmx8.47mm|Mouse pointer moving data]]
+| Moving
+|-
+| [[Image:copydata.png|border|left|8.47mmx8.47mm|Mouse pointer copying data]]
+| Copying
+|-
+| [[Image:linkdata.png|border|left|8.47mmx8.47mm|Mouse pointer inserting link]]
+| Creating a link
+|}
+
+If you press {{System|default=Ctrl|mac=Command}} or Shift+{{System|default=Ctrl|mac=Command}} while releasing the mouse button, you can control whether the object is copied, moved, or a link is created.
+
+{| border=&quot;1&quot;
+|-
+| [[Image:sc20238.png|border|left|5.64mmx5.64mm|Icon]]
+| If you drag objects out of the [[Common/Navigator_for_Document_Overview|Navigator]], you can specify in the submenu of the Navigator's '''Drag Mode''' icon whether to copy the object, insert it as a link or insert it as a hyperlink.
+|}
+
+{{Tip|You can cancel a drag-and-drop operation in {{ProductName}} at any time by pressing the Esc key before releasing the mouse button.}}
+
+'''Related Topics'''
+
+[[Common/Copying_Graphics_Between_Documents|Copying Graphics Between Documents]]
+
+[[Common/Copying_Spreadsheet_Areas_to_Text_Documents|Copying Spreadsheet Areas to Text Documents]]
+
+[[Common/Copying_Graphics_From_the_Gallery|Copying Graphics From the Gallery]]
+
+[[Common/Adding_Graphics_to_the_Gallery|Adding Graphics to the Gallery]]
+
+{{WhenInWriter|[[Writer/Moving_and_Copying_Text_in_Documents|Moving and Copying Text in Documents]]
+
+}}{{WhenInCalc|[[Calc/Referencing_Cells_by_Drag-and-Drop|Referencing Cells by Drag-and-Drop]]
+
+}}</text>
+ </revision>
+ </page>
</mediawiki>