'
+ resultStr = firstParagraphFromString(testStr)
+ assert resultStr == 'This is a test'
+
+ testStr = 'Testing without html'
+ resultStr = firstParagraphFromString(testStr)
+ assert resultStr == testStr
+
+
def runAllTests():
print('Running tests...')
+ testFirstParagraphFromString()
testGetNewswireTags()
testHashtagRuleTree()
testRemoveHtmlTag()
diff --git a/translations/ar.json b/translations/ar.json
index 1118a56b1..f39a708a8 100644
--- a/translations/ar.json
+++ b/translations/ar.json
@@ -327,5 +327,6 @@
"Create an article": "قم بإنشاء مقال",
"Settings": "إعدادات",
"Citations": "اقتباسات",
- "Choose newswire items referenced in your article": "اختر العناصر الإخبارية المشار إليها في مقالتك"
+ "Choose newswire items referenced in your article": "اختر العناصر الإخبارية المشار إليها في مقالتك",
+ "RSS feed for your blog": "تغذية RSS لمدونتك"
}
diff --git a/translations/ca.json b/translations/ca.json
index 797ad5469..29c09497c 100644
--- a/translations/ca.json
+++ b/translations/ca.json
@@ -327,5 +327,6 @@
"Create an article": "Creeu un article",
"Settings": "Configuració",
"Citations": "Cites",
- "Choose newswire items referenced in your article": "Trieu articles de newswire als quals faci referència el vostre article"
+ "Choose newswire items referenced in your article": "Trieu articles de newswire als quals faci referència el vostre article",
+ "RSS feed for your blog": "Feed RSS del vostre bloc"
}
diff --git a/translations/cy.json b/translations/cy.json
index d5cdb532d..d6791b73b 100644
--- a/translations/cy.json
+++ b/translations/cy.json
@@ -327,5 +327,6 @@
"Create an article": "Creu erthygl",
"Settings": "Gosodiadau",
"Citations": "Dyfyniadau",
- "Choose newswire items referenced in your article": "Dewiswch eitemau newyddion y cyfeirir atynt yn eich erthygl"
+ "Choose newswire items referenced in your article": "Dewiswch eitemau newyddion y cyfeirir atynt yn eich erthygl",
+ "RSS feed for your blog": "Porthiant RSS ar gyfer eich blog"
}
diff --git a/translations/de.json b/translations/de.json
index b8eb64df8..b9a4fd7ec 100644
--- a/translations/de.json
+++ b/translations/de.json
@@ -327,5 +327,6 @@
"Create an article": "Erstellen Sie einen Artikel",
"Settings": "Einstellungen",
"Citations": "Zitate",
- "Choose newswire items referenced in your article": "Wählen Sie Newswire-Artikel aus, auf die in Ihrem Artikel verwiesen wird"
+ "Choose newswire items referenced in your article": "Wählen Sie Newswire-Artikel aus, auf die in Ihrem Artikel verwiesen wird",
+ "RSS feed for your blog": "RSS-Feed für Ihr Blog"
}
diff --git a/translations/en.json b/translations/en.json
index 0b7b9b3c3..f2c6a566d 100644
--- a/translations/en.json
+++ b/translations/en.json
@@ -327,5 +327,6 @@
"Create an article": "Create an article",
"Settings": "Settings",
"Citations": "Citations",
- "Choose newswire items referenced in your article": "Choose newswire items referenced in your article"
+ "Choose newswire items referenced in your article": "Choose newswire items referenced in your article",
+ "RSS feed for your blog": "RSS feed for your blog"
}
diff --git a/translations/es.json b/translations/es.json
index dac48137c..693590fb6 100644
--- a/translations/es.json
+++ b/translations/es.json
@@ -327,5 +327,6 @@
"Create an article": "Crea un articulo",
"Settings": "Configuraciones",
"Citations": "Citas",
- "Choose newswire items referenced in your article": "Elija elementos de Newswire a los que se hace referencia en su artículo"
+ "Choose newswire items referenced in your article": "Elija elementos de Newswire a los que se hace referencia en su artículo",
+ "RSS feed for your blog": "Fuente RSS para tu blog"
}
diff --git a/translations/fr.json b/translations/fr.json
index e1edeefb3..f5422ddbb 100644
--- a/translations/fr.json
+++ b/translations/fr.json
@@ -327,5 +327,6 @@
"Create an article": "Créer un article",
"Settings": "Réglages",
"Citations": "Citations",
- "Choose newswire items referenced in your article": "Choisissez les éléments de fil d'actualité référencés dans votre article"
+ "Choose newswire items referenced in your article": "Choisissez les éléments de fil d'actualité référencés dans votre article",
+ "RSS feed for your blog": "Flux RSS pour votre blog"
}
diff --git a/translations/ga.json b/translations/ga.json
index ba28b61e6..3836db30d 100644
--- a/translations/ga.json
+++ b/translations/ga.json
@@ -327,5 +327,6 @@
"Create an article": "Cruthaigh alt",
"Settings": "Socruithe",
"Citations": "Citations",
- "Choose newswire items referenced in your article": "Roghnaigh míreanna sreanga nuachta dá dtagraítear i d’alt"
+ "Choose newswire items referenced in your article": "Roghnaigh míreanna sreanga nuachta dá dtagraítear i d’alt",
+ "RSS feed for your blog": "Fotha RSS do do bhlag"
}
diff --git a/translations/hi.json b/translations/hi.json
index 11daf17df..31b486e7f 100644
--- a/translations/hi.json
+++ b/translations/hi.json
@@ -327,5 +327,6 @@
"Create an article": "एक लेख बनाएँ",
"Settings": "समायोजन",
"Citations": "उद्धरण",
- "Choose newswire items referenced in your article": "अपने लेख में संदर्भित newswire आइटम चुनें"
+ "Choose newswire items referenced in your article": "अपने लेख में संदर्भित newswire आइटम चुनें",
+ "RSS feed for your blog": "RSS आपके ब्लॉग के लिए फ़ीड करता है"
}
diff --git a/translations/it.json b/translations/it.json
index 2470fc5d9..f65e18c98 100644
--- a/translations/it.json
+++ b/translations/it.json
@@ -327,5 +327,6 @@
"Create an article": "Crea un articolo",
"Settings": "impostazioni",
"Citations": "Citazioni",
- "Choose newswire items referenced in your article": "Scegli gli articoli del newswire a cui fa riferimento il tuo articolo"
+ "Choose newswire items referenced in your article": "Scegli gli articoli del newswire a cui fa riferimento il tuo articolo",
+ "RSS feed for your blog": "Feed RSS per il tuo blog"
}
diff --git a/translations/ja.json b/translations/ja.json
index d6b71d6ca..bafa38784 100644
--- a/translations/ja.json
+++ b/translations/ja.json
@@ -327,5 +327,6 @@
"Create an article": "記事を作成する",
"Settings": "設定",
"Citations": "引用",
- "Choose newswire items referenced in your article": "あなたの記事で参照されているニュースワイヤーアイテムを選択してください"
+ "Choose newswire items referenced in your article": "あなたの記事で参照されているニュースワイヤーアイテムを選択してください",
+ "RSS feed for your blog": "ブログのRSSフィード"
}
diff --git a/translations/oc.json b/translations/oc.json
index efda869e1..250302075 100644
--- a/translations/oc.json
+++ b/translations/oc.json
@@ -323,5 +323,6 @@
"Create an article": "Create an article",
"Settings": "Settings",
"Citations": "Citations",
- "Choose newswire items referenced in your article": "Choose newswire items referenced in your article"
+ "Choose newswire items referenced in your article": "Choose newswire items referenced in your article",
+ "RSS feed for your blog": "RSS feed for your blog"
}
diff --git a/translations/pt.json b/translations/pt.json
index 316fdcf85..831c1d106 100644
--- a/translations/pt.json
+++ b/translations/pt.json
@@ -327,5 +327,6 @@
"Create an article": "Crie um artigo",
"Settings": "Definições",
"Citations": "Citações",
- "Choose newswire items referenced in your article": "Escolha os itens de notícias mencionados em seu artigo"
+ "Choose newswire items referenced in your article": "Escolha os itens de notícias mencionados em seu artigo",
+ "RSS feed for your blog": "Feed RSS para o seu blog"
}
diff --git a/translations/ru.json b/translations/ru.json
index 885238420..2665feb49 100644
--- a/translations/ru.json
+++ b/translations/ru.json
@@ -327,5 +327,6 @@
"Create an article": "Создать статью",
"Settings": "Настройки",
"Citations": "Цитаты",
- "Choose newswire items referenced in your article": "Выберите элементы ленты новостей, на которые есть ссылки в вашей статье"
+ "Choose newswire items referenced in your article": "Выберите элементы ленты новостей, на которые есть ссылки в вашей статье",
+ "RSS feed for your blog": "RSS-канал для вашего блога"
}
diff --git a/translations/zh.json b/translations/zh.json
index f7ba586ec..635ceeeff 100644
--- a/translations/zh.json
+++ b/translations/zh.json
@@ -327,5 +327,6 @@
"Create an article": "建立文章",
"Settings": "设定值",
"Citations": "引文",
- "Choose newswire items referenced in your article": "选择文章中引用的新闻专栏文章"
+ "Choose newswire items referenced in your article": "选择文章中引用的新闻专栏文章",
+ "RSS feed for your blog": "您博客的RSS供稿"
}
diff --git a/utils.py b/utils.py
index 08d21f159..8989b7f52 100644
--- a/utils.py
+++ b/utils.py
@@ -38,6 +38,18 @@ def removeHtml(content: str) -> str:
return result
+def firstParagraphFromString(content: str) -> str:
+ """Get the first paragraph from a blog post
+ to be used as a summary in the newswire feed
+ """
+ if '
' not in content or '
' not in content:
+ return removeHtml(content)
+ paragraph = content.split('
')[1]
+ if '
' in paragraph:
+ paragraph = paragraph.split('
')[0]
+ return removeHtml(paragraph)
+
+
def isSystemAccount(nickname: str) -> bool:
"""Returns true if the given nickname is a system account
"""
@@ -1482,3 +1494,11 @@ def siteIsActive(url: str) -> bool:
if e.errno == errno.ECONNRESET:
print('WARN: connection was reset during siteIsActive')
return False
+
+
+def weekDayOfMonthStart(monthNumber: int, year: int) -> int:
+ """Gets the day number of the first day of the month
+ 1=sun, 7=sat
+ """
+ firstDayOfMonth = datetime.datetime(year, monthNumber, 1, 0, 0)
+ return int(firstDayOfMonth.strftime("%w")) + 1
diff --git a/webapp.py b/webapp.py
new file mode 100644
index 000000000..f51ff06ff
--- /dev/null
+++ b/webapp.py
@@ -0,0 +1,771 @@
+__filename__ = "webapp.py"
+__author__ = "Bob Mottram"
+__license__ = "AGPL3+"
+__version__ = "1.1.0"
+__maintainer__ = "Bob Mottram"
+__email__ = "bob@freedombone.net"
+__status__ = "Production"
+
+import time
+import os
+from shutil import copyfile
+from utils import getCSS
+from utils import getNicknameFromActor
+from utils import getDomainFromActor
+from utils import locatePost
+from utils import noOfAccounts
+from utils import loadJson
+from utils import getConfigParam
+from posts import isEditor
+from shares import getValidSharedItemID
+from webapp_utils import getAltPath
+from webapp_utils import getIconsDir
+from webapp_utils import htmlHeader
+from webapp_utils import htmlFooter
+from webapp_post import individualPostAsHtml
+
+
+def htmlFollowingList(cssCache: {}, baseDir: str,
+ followingFilename: str) -> str:
+ """Returns a list of handles being followed
+ """
+ with open(followingFilename, 'r') as followingFile:
+ msg = followingFile.read()
+ followingList = msg.split('\n')
+ followingList.sort()
+ if followingList:
+ cssFilename = baseDir + '/epicyon-profile.css'
+ if os.path.isfile(baseDir + '/epicyon.css'):
+ cssFilename = baseDir + '/epicyon.css'
+
+ profileCSS = getCSS(baseDir, cssFilename, cssCache)
+ if profileCSS:
+ followingListHtml = htmlHeader(cssFilename, profileCSS)
+ for followingAddress in followingList:
+ if followingAddress:
+ followingListHtml += \
+ '
@' + followingAddress + '
'
+ followingListHtml += htmlFooter()
+ msg = followingListHtml
+ return msg
+ return ''
+
+
+def htmlModerationInfo(cssCache: {}, translate: {},
+ baseDir: str, httpPrefix: str) -> str:
+ msgStr1 = \
+ 'These are globally blocked for all accounts on this instance'
+ msgStr2 = \
+ 'Any blocks or suspensions made by moderators will be shown here.'
+ infoForm = ''
+ cssFilename = baseDir + '/epicyon-profile.css'
+ if os.path.isfile(baseDir + '/epicyon.css'):
+ cssFilename = baseDir + '/epicyon.css'
+
+ infoCSS = getCSS(baseDir, cssFilename, cssCache)
+ if infoCSS:
+ if httpPrefix != 'https':
+ infoCSS = infoCSS.replace('https://',
+ httpPrefix + '://')
+ infoForm = htmlHeader(cssFilename, infoCSS)
+
+ infoForm += \
+ '