diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-12-06 16:18:54 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-12-06 16:18:54 +0100 |
commit | f6f254c8f79d727fe3235a746ddd00a4b62e6595 (patch) | |
tree | d7dd6f4bbce20da75eebd56415b7a58b07064cc4 /helpcontent2/to-wiki | |
parent | 7a3cef460b8ca5dd12647756ee8206f7f8c6d679 (diff) |
wikihelp: Make the redirects more stable.
feature/currency-64bit
Still it is not perfect for duplicates of 'branch' attribute in bookmarks, but
what can we do...
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-x | helpcontent2/to-wiki/wikiconv2.py | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py index 8e64fd4762..a160779b04 100755 --- a/helpcontent2/to-wiki/wikiconv2.py +++ b/helpcontent2/to-wiki/wikiconv2.py @@ -372,6 +372,7 @@ class Bookmark(ElementBase): self.app = '' self.redirect = '' self.target = '' + self.authoritative = False # let's construct the name of the redirect, so that we can point # to the wikihelp directly from the LO code; wiki then takes care of @@ -382,6 +383,7 @@ class Bookmark(ElementBase): self.app = parser.current_app_raw self.target = parser.wiki_page_name + self.authoritative = parser.follow_embed if name.find('.uno:') == 0 or name.find('.HelpId:') == 0: self.redirect = name elif name.upper() in hid_lst: @@ -393,12 +395,8 @@ class Bookmark(ElementBase): global redirects # first of all, we need to create a redirect page for this one if self.redirect != '' and self.target != '': - if self.app != '': - redirects.append(['%s/%s'% (self.app, self.redirect), self.target]) - else: - for i in ['swriter', 'scalc', 'simpress', 'sdraw', 'smath', \ - 'schart', 'sbasic', 'sdatabase']: - redirects.append(['%s/%s'% (i, self.redirect), self.target]) + redirects.append([self.app, self.redirect, self.target, \ + self.authoritative]) # then we also have to setup ID inside the page if self.type == 'div': @@ -1145,14 +1143,49 @@ for image in images: file.close() # generate the redirects -print 'Generating the redirects...' -for redir in redirects: - fname = 'wiki/%s'% redir[0] +def write_link(r, target): + fname = 'wiki/%s'% r try: file = open(fname, "w") - file.write('#REDIRECT [[%s]]\n'% redir[1]) + file.write('#REDIRECT [[%s]]\n'% target) file.close() except: sys.stderr.write('Unable to write "%s".\n'%'wiki/%s'% fname) +print 'Generating the redirects...' +written = {} +# in the first pass, immediately writte the links that are embedded, so that +# we can always point to that source versions +for redir in redirects: + app = redir[0] + redirect = redir[1] + target = redir[2] + authoritative = redir[3] + + if app != '': + r = '%s/%s'% (app, redirect) + if authoritative: + write_link(r, target) + written[r] = True + else: + try: + written[r] + except: + written[r] = False + +# in the second pass, output the wiki links +for redir in redirects: + app = redir[0] + redirect = redir[1] + target = redir[2] + + if app == '': + for i in ['swriter', 'scalc', 'simpress', 'sdraw', 'smath', \ + 'schart', 'sbasic', 'sdatabase']: + write_link('%s/%s'% (i, redirect), target) + else: + r = '%s/%s'% (app, redirect) + if not written[r]: + write_link(r, target) + # vim:set shiftwidth=4 softtabstop=4 expandtab: |