Added CodiMD support

This commit is contained in:
datalets 2021-02-23 15:47:37 +01:00
commit 926c7d993e
4 changed files with 23 additions and 9 deletions

View file

@ -14,19 +14,19 @@ jobs:
strategy:
matrix:
name: [
"windows",
"macos",
"windows",
"ubuntu",
]
include:
- name: "windows"
os: windows-latest
python-version: 3.8
- name: "macos"
- name: "macos-3.7"
os: macos-latest
python-version: 3.7
- name: "ubuntu"
os: ubuntu-20.04
- name: "windows-3.8"
os: windows-latest
python-version: 3.8
- name: "ubuntu-3.9"
os: ubuntu-latest
python-version: 3.9
steps:
- uses: actions/checkout@v2

View file

@ -10,7 +10,7 @@ from future.standard_library import install_aliases
install_aliases()
from urllib.parse import quote_plus
from bleach.sanitizer import ALLOWED_TAGS, ALLOWED_ATTRIBUTES
from flask_misaka import markdown
from base64 import b64decode
from pyquery import PyQuery as pq
@ -177,6 +177,20 @@ def FetchWebProject(project_url):
obj['source_url'] = project_url
obj['image_url'] = "/static/img/document_icon.png"
# CodiMD / HackMD
elif data.text.find('<div id="doc" ')>0:
doc = pq(data.text)
ptitle = doc("title")
if len(ptitle) < 1: return {}
content = doc("div#doc").html()
if len(content) < 1: return {}
obj['type'] = 'Markdown'
obj['name'] = ptitle.text()
obj['description'] = markdown(content)
obj['source_url'] = project_url
obj['image_url'] = "/static/img/codimd.png"
# DokuWiki
elif data.text.find('<meta name="generator" content="DokuWiki"/>')>0:
doc = pq(data.text)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -48,7 +48,7 @@
$indicator.find('i').css('color', 'green');
$button.removeAttr('disabled').html('Update now');
if (typeof data.name === 'undefined' || data.name === '') {
window.alert('Project data could not be fetched - enter a valid Remote link.');
window.alert('Project data could not be fetched - enter a valid Sync link.');
$('#is_autoupdate').prop('checked', false);
return;
}