From 640a6325f09499bc353c0e6f730ccb754131c34f Mon Sep 17 00:00:00 2001
From: Ciaran Gultnieks
' + self.state = self.stPARA + elif self.state == self.stPARA: + self.text_html += ' ' + self.text_plain += ' ' + self.addtext(line) + + def end(self): + self.endcur() # Parse multiple lines of description as written in a metadata file, returning -# a single string. -def parse_description(lines): - text = '' +# a single string in plain text format. +def description_plain(lines, linkres): + ps = DescriptionFormatter(linkres) for line in lines: - if len(line) == 0: - text += '\n\n' - else: - if not text.endswith('\n') and len(text) > 0: - text += ' ' - text += line - return text + ps.parseline(line) + ps.end() + return ps.text_plain + +# Parse multiple lines of description as written in a metadata file, returning +# a single string in wiki format. +def description_wiki(lines): + ps = DescriptionFormatter(None) + for line in lines: + ps.parseline(line) + ps.end() + return ps.text_wiki + +# Parse multiple lines of description as written in a metadata file, returning +# a single string in HTML format. +def description_html(lines,linkres): + ps = DescriptionFormatter(linkres) + for line in lines: + ps.parseline(line) + ps.end() + return ps.text_html + # Extract some information from the AndroidManifest.xml at the given path. diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 89cb1676..a7dceaaf 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -30,7 +30,7 @@ from xml.dom.minidom import Document from optparse import OptionParser import time import common - +from common import MetaDataException # Update the wiki. 'apps' is a list of all applications and everything we know # about them, and 'apks' likewise. Set 'verbose' to True for verbose output. @@ -66,7 +66,7 @@ def update_wiki(apps, apks, verbose=False): wikidata += " - [http://f-droid.org/repository/browse/?fdid=" + app['id'] + " view in repository]\n\n" wikidata += "=Description=\n" - wikidata += common.parse_description(app['Description']) + "\n" + wikidata += common.description_wiki(app['Description']) + "\n" # Get a list of all packages for this application... apklist = [] @@ -438,6 +438,10 @@ def main(): el = doc.createElement(name) el.appendChild(doc.createTextNode(value)) parent.appendChild(el) + def addElementCDATA(name, value, doc, parent): + el = doc.createElement(name) + el.appendChild(doc.createCDATASection(value)) + parent.appendChild(el) root = doc.createElement("fdroid") doc.appendChild(root) @@ -510,8 +514,15 @@ def main(): addElement('name', app['Name'], doc, apel) addElement('summary', app['Summary'], doc, apel) addElement('icon', app['icon'], doc, apel) + def linkres(link): + for app in apps: + if app['id'] == link: + return ("fdroid.app:" + link, app['Name']) + raise MetaDataException("Cannot resolve app id " + link) addElement('description', - common.parse_description(app['Description']), doc, apel) + common.description_plain(app['Description'], linkres), doc, apel) + addElement('desc', + common.description_html(app['Description'], linkres), doc, apel) addElement('license', app['License'], doc, apel) if 'Category' in app: # We put the first (primary) category in LAST, which will have