mirror of
https://codeberg.org/dribdat/dribdat.git
synced 2026-03-14 07:16:12 +00:00
Pretalx support #432
This commit is contained in:
parent
5f00707ba6
commit
dfbdba3037
4 changed files with 41 additions and 7 deletions
|
|
@ -362,6 +362,9 @@ def FetchWebProject(project_url):
|
|||
# Instructables
|
||||
elif project_url.startswith('https://www.instructables.com/'):
|
||||
return FetchWebInstructables(datatext, project_url)
|
||||
# Pretalx
|
||||
elif datatext.find('<meta name="generator" content="pretalx">') > 0:
|
||||
return FetchWebPretalx(datatext, project_url)
|
||||
# CodiMD / HackMD
|
||||
elif datatext.find('<div id="doc" ') > 0:
|
||||
return FetchWebCodiMD(datatext, project_url)
|
||||
|
|
@ -547,3 +550,23 @@ def ParseInstructablesElement(elem):
|
|||
tags=ALLOWED_HTML_TAGS,
|
||||
attributes=ALLOWED_HTML_ATTR)
|
||||
return elem.tag, p
|
||||
|
||||
|
||||
def FetchWebPretalx(text, url):
|
||||
"""Grab Pretalx data from a talk."""
|
||||
if not '/talk/' in url:
|
||||
return {}
|
||||
doc = pq(text)
|
||||
apiurl = doc('link[@rel="alternate"]').attr('href')
|
||||
rawdata = requests.get(apiurl + '?format=json', timeout=REQUEST_TIMEOUT)
|
||||
if rawdata.text.find('{') < 0:
|
||||
return {}
|
||||
jsondata = rawdata.json()
|
||||
return {
|
||||
'type': 'Pretalx',
|
||||
'name': jsondata['title'],
|
||||
'summary': jsondata['abstract'][:2000],
|
||||
'description': jsondata['description'],
|
||||
'source_url': url,
|
||||
'logo_icon': 'window-maximize',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,13 +66,13 @@ if current_event.boilerplate %}
|
|||
</div>
|
||||
</a>
|
||||
<a
|
||||
href="http://instructables.com/"
|
||||
href="http://pretalx.com/"
|
||||
target="_blank"
|
||||
class="media col-sm text-default"
|
||||
>
|
||||
<i class="mr-3 fa fa-cog" alt="Logo"></i>
|
||||
<i class="mr-3 fa fa-window-maximize" alt="Logo"></i>
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0 mb-1">Instructables</h5>
|
||||
<h5 class="mt-0 mb-1">Pretalx</h5>
|
||||
</div>
|
||||
</a>
|
||||
<a
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"boilerplate": "### 🚀 Let's launch your idea!\r\n\r\nWrite a **Title** and short **Summary**, select a **Template** if one is available, or use the **Readme** link to fetch an open source repository on [GitHub](https://github.com), [GitLab](https://gitlab.com) or [Bitbucket](https://bitbucket.org); an online document at [Etherpad](http://etherpad.org), [Instructables](http://instructables.com), [HackMD or CodiMD](https://hackmd.io), [Google Docs](http://docs.google.com) (Published to Web) or [DokuWiki](http://make.opendata.ch/wiki/project:home).\r\n\r\n_Need more help?_ Get in touch with the organising team, or raise [an issue](https://github.com/dribdat/dribdat/issues).\r\n",
|
||||
"boilerplate": "### 🚀 Let's launch your idea!\r\n\r\nWrite a **Title** and short **Summary**, select a **Template** if one is available, or use the **Readme** link to fetch an open source repository on [GitHub](https://github.com), [GitLab](https://gitlab.com) or [Bitbucket](https://bitbucket.org); an online document at [Etherpad](http://etherpad.org), [Pretalx](http://pretalx.com), [HackMD or CodiMD](https://hackmd.io), [Google Docs](http://docs.google.com) (Published to Web) or [DokuWiki](http://make.opendata.ch/wiki/project:home).\r\n\r\n_Need more help?_ Get in touch with the organising team, or raise [an issue](https://github.com/dribdat/dribdat/issues).\r\n",
|
||||
"certificate_path": "",
|
||||
"community_embed": "<div class=\"codeofconduct\">All attendees, sponsors, partners, volunteers and staff at our hackathon are required to agree with the <a href=\"https://hackcodeofconduct.org/\" target=\"_blank\">Hack Code of Conduct</a>. Organisers will enforce this code throughout the event. We expect cooperation from all participants to ensure a safe environment for everybody.</div>\r\n\r\n<br><p><a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\" target=\"_blank\"><img align=\"left\" style=\"margin-right:1em\" alt=\"Creative Commons Licence\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by/4.0/88x31.png\" /></a>The contents of this website, unless otherwise stated, are licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by/4.0/\" target=\"_blank\">Creative Commons Attribution 4.0 International License</a>.</p>\r\n",
|
||||
"community_url": "https://github.com/dribdat/awesome-hackathon",
|
||||
|
|
@ -105,4 +105,4 @@
|
|||
],
|
||||
"title": "Awesome hackathon",
|
||||
"version": "0.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
from dribdat.aggregation import (
|
||||
AddProjectDataFromAutotext,
|
||||
SyncProjectData,
|
||||
TrimProjectData,
|
||||
TrimProjectData,
|
||||
FetchWebProject,
|
||||
ProjectActivity,
|
||||
)
|
||||
|
|
@ -18,7 +18,7 @@ from string import ascii_uppercase
|
|||
|
||||
class TestSync:
|
||||
"""Testing sync and aggregation features."""
|
||||
|
||||
|
||||
a_long_random_string = ''.join(random.choices(ascii_uppercase, k=5000))
|
||||
|
||||
def test_data_sync(self, user, testapp):
|
||||
|
|
@ -90,3 +90,14 @@ class TestSync:
|
|||
assert imgroot in readme
|
||||
assert not '(world.png)' in readme
|
||||
assert not '"again.jpg"' in readme
|
||||
|
||||
|
||||
def test_pretalx(self):
|
||||
"""Test parsing a Pretalx page."""
|
||||
test_url = 'https://pretalx.com/workshoptage-2024/talk/QKRVRA/'
|
||||
test_obj = FetchWebProject(test_url)
|
||||
assert test_obj['type'] == 'Pretalx'
|
||||
assert test_obj['source_url'] == test_url
|
||||
assert 'Open' in test_obj['name']
|
||||
assert 'Grundlagen' in test_obj['summary']
|
||||
assert 'Downstreaming' in test_obj['description']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue