diff --git a/migrate.py b/migrate.py
index 92e3f21e..1bec3a73 100644
--- a/migrate.py
+++ b/migrate.py
@@ -166,8 +166,8 @@ def export_body(article, content_dict):
article = extract_images(article)
metadata = get_metadata(article)
content = frontmatter.dumps(frontmatter.Post(article['body'], **metadata))
- open('../content/discours.io/'+slug+'.md', 'w').write(content)
- open('../content/discours.io/'+slug+'.html', 'w').write(content_dict[article['old_id']]['body'])
+ open('../discoursio-web/content/' + article['layout'].lower() + '/' + slug + '.mdx', 'w').write(content)
+ # open('../content/discours.io/'+slug+'.html', 'w').write(content_dict[article['old_id']]['body'])
def export_slug(slug, export_articles, export_authors, content_dict):
print('exporting %s ' % slug)
diff --git a/migration/html2text/__init__.py b/migration/html2text/__init__.py
index 0e521760..c50241d0 100644
--- a/migration/html2text/__init__.py
+++ b/migration/html2text/__init__.py
@@ -385,7 +385,7 @@ class HTML2Text(html.parser.HTMLParser):
elif self.current_class == 'lead' and \
self.inheader == False and \
self.span_highlight == False:
- self.o('==') # NOTE: but CriticMarkup uses {== ==}
+ self.o("==") # NOTE: but CriticMarkup uses {== ==}
self.span_lead = True
else:
if self.span_highlight:
@@ -478,7 +478,8 @@ class HTML2Text(html.parser.HTMLParser):
else:
strong = self.strong_mark
- self.o(strong)
+ if not self.span_lead and not self.span_highlight:
+ self.o(strong)
if start:
self.stressed = True
diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py
index 78d1c3b8..759f8549 100644
--- a/migration/tables/content_items.py
+++ b/migration/tables/content_items.py
@@ -12,7 +12,8 @@ from datetime import datetime
from sqlalchemy.exc import IntegrityError
from orm.base import local_session
from orm.community import Community
-
+import os
+
DISCOURS_USER = {
'id': 9999999,
'slug': 'discours',
@@ -124,30 +125,37 @@ def migrate(entry, users_by_oid, topics_by_oid):
yt = m.get('youtubeId', '')
vm = m.get('vimeoId', '')
video_url = 'https://www.youtube.com/watch?v=' + yt if yt else '#'
+ therestof = html2text(m.get('body', entry.get('body', '')))
+ r['body'] = 'import { YouTube } from \"solid-social\"\n' + \
+ '\n\n' + therestof
if video_url == '#':
video_url = 'https://vimeo.com/' + vm if vm else '#'
+ r['body'] = 'import { Vimeo } from \"solid-social\"\n' + \
+ '\n\n' + therestof
if video_url == '#':
print(entry.get('media', 'UNKNOWN MEDIA PROVIDER!'))
# raise Exception
- therestof = html2text(m.get('body', ''))
- r['body'] = 'import VideoPlayer from \"src/components/Article/VideoPlayer\"\n' + \
- '\n\n' + therestof
elif entry.get('type') == 'Music':
- r['body'] = 'import MusicPlayer from \"src/components/MusicPlayer\"\n'
+ r['body'] = ''
for m in entry['media']:
if m == { 'main': 'true' } or m == { 'main': True } or m == {}:
continue
- # TODO: mark highlighted track isMain == True
- try: r['body'] += '\n\n'
- r['body'] += html2text(m.get('body', ''))
+ else:
+ # TODO: mark highlighted track isMain == True
+ fileUrl = m.get('fileUrl', '')
+ if not fileUrl:
+ print(m)
+ continue
+ else:
+ r['body'] = 'import MusicPlayer from \"src/components/MusicPlayer\"\n\n'
+ r['body'] += '\n'
+ r['body'] += html2text(entry.get('body', ''))
elif entry.get('type') == 'Image':
m = r.get('media')
- try: r['body'] = '
'
- except: print(entry)
+ r['body'] = ''
+ if 'cover' in r: r['body'] = '
'
+ r['body'] += entry.get('body', '')
+ if r['body'] == '': print(entry)
if r.get('body') is None:
body_orig = entry.get('body', '')
body_html = str(BeautifulSoup(body_orig, features="html.parser"))
@@ -191,7 +199,10 @@ def migrate(entry, users_by_oid, topics_by_oid):
metadata = get_metadata(shout_dict)
content = frontmatter.dumps(frontmatter.Post(body, **metadata))
ext = 'mdx'
- open('../discoursio-web/content/' + r['layout'] + '/' + r['slug'] + '.' + ext, 'w').write(content)
+ parentDir = '/'.join(os.getcwd().split('/')[:-1])
+ filepath = parentDir + '/discoursio-web/content/' + r['layout'] + '/' + r['slug'] + '.' + ext
+ # print(filepath)
+ open(filepath, 'w').write(content)
try:
shout_dict['createdAt'] = date_parse(r.get('createdAt')) if entry.get('createdAt') else ts
shout_dict['publishedAt'] = date_parse(entry.get('publishedAt')) if entry.get('published') else None
diff --git a/resolvers/zine.py b/resolvers/zine.py
index 9a94872c..357e1910 100644
--- a/resolvers/zine.py
+++ b/resolvers/zine.py
@@ -57,7 +57,7 @@ class GitTask:
#output = subprocess.check_output(cmd, shell=True)
#print(output)
- shout_filename = "%s.md" % (self.slug)
+ shout_filename = "%s.mdx" % (self.slug)
shout_full_filename = "%s/%s" % (repo_path, shout_filename)
with open(shout_full_filename, mode='w', encoding='utf-8') as shout_file:
shout_file.write(self.shout_body)