diff --git a/examples/config.yml b/examples/config.yml index 484ecc71..e022e389 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -54,7 +54,7 @@ repo_url: https://MyFirstFDroidRepo.org/fdroid/repo repo_name: My First F-Droid Repo Demo repo_icon: fdroid-icon.png -repo_description: | +repo_description: >- This is a repository of apps to be used with F-Droid. Applications in this repository are either official binaries built by the original application developers, or are binaries built from source by the admin of f-droid.org @@ -68,7 +68,7 @@ archive_older: 3 archive_url: https://f-droid.org/archive archive_name: My First F-Droid Archive Demo archive_icon: fdroid-icon.png -archive_description: | +archive_description: >- The repository of older versions of packages from the main demo repository. # This allows a specific kind of insecure APK to be included in the diff --git a/fdroidserver/common.py b/fdroidserver/common.py index c75338f1..a9f14c23 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -355,10 +355,6 @@ def read_config(opts): fill_config_defaults(config) - for k in ["repo_description", "archive_description"]: - if k in config: - config[k] = clean_description(config[k]) - if 'serverwebroot' in config: if isinstance(config['serverwebroot'], str): roots = [config['serverwebroot']] @@ -671,19 +667,6 @@ def get_extension(filename): publish_name_regex = re.compile(r"^(.+)_([0-9]+)\.(apk|zip)$") -def clean_description(description): - 'Remove unneeded newlines and spaces from a block of description text' - returnstring = '' - # this is split up by paragraph to make removing the newlines easier - for paragraph in re.split(r'\n\n', description): - paragraph = re.sub('\r', '', paragraph) - paragraph = re.sub('\n', ' ', paragraph) - paragraph = re.sub(' {2,}', ' ', paragraph) - paragraph = re.sub(r'^\s*(\w)', r'\1', paragraph) - returnstring += paragraph + '\n\n' - return returnstring.rstrip('\n') - - def publishednameinfo(filename): filename = os.path.basename(filename) m = publish_name_regex.match(filename) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 078b64fb..e707824d 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -405,7 +405,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing addElement('icon', app.icon, doc, apel) addElementCheckLocalized('desc', app, 'Description', doc, apel, - '

No description available

') + 'No description available') addElement('license', app.License, doc, apel) if app.Categories: diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index dd48e05f..b5acc9ad 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -583,7 +583,7 @@ def main(): config = common.read_config(options) # Get all apps... - allapps = metadata.read_metadata(xref=True) + allapps = metadata.read_metadata(options.appid) apps = common.read_app_args(options.appid, allapps, False) anywarns = check_for_unsupported_metadata_files() diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 79195289..209943be 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -21,10 +21,7 @@ import os import re import glob -import html import logging -import textwrap -import io import yaml try: from yaml import CSafeLoader as SafeLoader @@ -467,196 +464,6 @@ def check_metadata(app): v.check(app[k], app.id) -# Formatter for descriptions. Create an instance, and call parseline() with -# each line of the description source from the metadata. At the end, call -# end() and then text_txt and text_html will contain the result. -class DescriptionFormatter: - - stNONE = 0 - stPARA = 1 - stUL = 2 - stOL = 3 - - def __init__(self, linkres): - self.bold = False - self.ital = False - self.state = self.stNONE - self.laststate = self.stNONE - self.text_html = '' - self.text_txt = '' - self.html = io.StringIO() - self.text = io.StringIO() - self.para_lines = [] - self.linkResolver = None - self.linkResolver = linkres - - def endcur(self, notstates=None): - if notstates and self.state in notstates: - return - if self.state == self.stPARA: - self.endpara() - elif self.state == self.stUL: - self.endul() - elif self.state == self.stOL: - self.endol() - - def endpara(self): - self.laststate = self.state - self.state = self.stNONE - whole_para = ' '.join(self.para_lines) - self.addtext(whole_para) - wrapped = textwrap.fill(whole_para, 80, - break_long_words=False, - break_on_hyphens=False) - self.text.write(wrapped) - self.html.write('

') - del self.para_lines[:] - - def endul(self): - self.html.write('') - self.laststate = self.state - self.state = self.stNONE - - def endol(self): - self.html.write('') - self.laststate = self.state - self.state = self.stNONE - - def formatted(self, txt, htmlbody): - res = '' - if htmlbody: - txt = html.escape(txt, quote=False) - while True: - index = txt.find("''") - if index == -1: - return res + txt - res += txt[:index] - txt = txt[index:] - if txt.startswith("'''"): - if htmlbody: - if self.bold: - res += '' - else: - res += '' - self.bold = not self.bold - txt = txt[3:] - else: - if htmlbody: - if self.ital: - res += '' - else: - res += '' - self.ital = not self.ital - txt = txt[2:] - - def linkify(self, txt): - res_plain = '' - res_html = '' - while True: - index = txt.find("[") - if index == -1: - return (res_plain + self.formatted(txt, False), res_html + self.formatted(txt, True)) - res_plain += self.formatted(txt[:index], False) - res_html += self.formatted(txt[:index], True) - txt = txt[index:] - if txt.startswith("[["): - index = txt.find("]]") - if index == -1: - _warn_or_exception(_("Unterminated ]]")) - url = txt[2:index] - if self.linkResolver: - url, urltext = self.linkResolver.resolve_description_link(url) - else: - urltext = url - res_html += '' + html.escape(urltext, quote=False) + '' - res_plain += urltext - txt = txt[index + 2:] - else: - index = txt.find("]") - if index == -1: - _warn_or_exception(_("Unterminated ]")) - url = txt[1:index] - index2 = url.find(' ') - if index2 == -1: - urltxt = url - else: - urltxt = url[index2 + 1:] - url = url[:index2] - if url == urltxt: - _warn_or_exception(_("URL title is just the URL, use brackets: [URL]")) - res_html += '' + html.escape(urltxt, quote=False) + '' - res_plain += urltxt - if urltxt != url: - res_plain += ' (' + url + ')' - txt = txt[index + 1:] - - def addtext(self, txt): - p, h = self.linkify(txt) - self.html.write(h) - - def parseline(self, line): - if not line: - self.endcur() - elif line.startswith('* '): - self.endcur([self.stUL]) - if self.state != self.stUL: - self.html.write('