forked from indymedia/epicyon
Multi CSS; Alter HTML generation
parent
5d34e0d4be
commit
2171fd07a1
|
|
@ -8,13 +8,16 @@ __status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import isPublicPostFromUrl
|
from utils import isPublicPostFromUrl
|
||||||
|
from utils import getConfigParam
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getImageFormats
|
from utils import getImageFormats
|
||||||
from utils import getMediaFormats
|
from utils import getMediaFormats
|
||||||
from webapp_utils import getBannerFile
|
from webapp_utils import getBannerFile
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyles
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
|
from webapp_headerbuttons import headerButtonsTimeline, headerNewsTabs
|
||||||
|
from posts import isModerator
|
||||||
|
|
||||||
|
|
||||||
def _htmlFollowingDataList(baseDir: str, nickname: str,
|
def _htmlFollowingDataList(baseDir: str, nickname: str,
|
||||||
|
|
@ -250,9 +253,21 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
newPostText = \
|
newPostText = \
|
||||||
'<p>' + file.read() + '</p>\n'
|
'<p>' + file.read() + '</p>\n'
|
||||||
|
|
||||||
cssFilename = baseDir + '/epicyon-profile.css'
|
cssFiles = []
|
||||||
|
|
||||||
|
cssFiles.append(baseDir + '/epicyon-profile.css')
|
||||||
if os.path.isfile(baseDir + '/epicyon.css'):
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
cssFilename = baseDir + '/epicyon.css'
|
cssFiles[0] = baseDir + '/epicyon.css'
|
||||||
|
|
||||||
|
# TODO: Clean up and remove this override
|
||||||
|
cssFiles[0] = 'base.css'
|
||||||
|
|
||||||
|
# Get theme-specific css if exists - must be named '<theme-name>.css'
|
||||||
|
themeName = getConfigParam(baseDir, 'theme')
|
||||||
|
|
||||||
|
themePath = f'{baseDir}/theme/{themeName}.css'
|
||||||
|
if os.path.isfile(themePath):
|
||||||
|
cssFiles.append('theme/' + themeName + '.css')
|
||||||
|
|
||||||
if '?' in path:
|
if '?' in path:
|
||||||
path = path.split('?')[0]
|
path = path.split('?')[0]
|
||||||
|
|
@ -555,16 +570,39 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
dateAndLocation += '<input type="text" name="category">\n'
|
dateAndLocation += '<input type="text" name="category">\n'
|
||||||
dateAndLocation += '</div>\n'
|
dateAndLocation += '</div>\n'
|
||||||
|
|
||||||
newPostForm = htmlHeaderWithExternalStyle(cssFilename)
|
newPostForm = htmlHeaderWithExternalStyles(cssFiles)
|
||||||
|
|
||||||
newPostForm += \
|
usersPath = '/users/' + nickname
|
||||||
'<header>\n' + \
|
|
||||||
'<a href="/users/' + nickname + '/' + defaultTimeline + '" title="' + \
|
newPostForm += '<div class="header">\n'
|
||||||
translate['Switch to timeline view'] + '" alt="' + \
|
|
||||||
translate['Switch to timeline view'] + '">\n'
|
if not defaultTimeline == 'tlfeatures':
|
||||||
newPostForm += '<img loading="lazy" class="timeline-banner" src="' + \
|
newPostForm += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/{defaultTimeline}\" "
|
||||||
'/users/' + nickname + '/' + bannerFile + '" /></a>\n' + \
|
f"style=\"background-image: url('{usersPath}/{bannerFile}');\">"
|
||||||
'</header>\n'
|
f"{translate['Switch to timeline view']}</a>\n")
|
||||||
|
else:
|
||||||
|
# TODO: News instances should ignore personalised banners
|
||||||
|
# Currently uses the 'news' actor banner - as it remains unchanged
|
||||||
|
newPostForm += (f"\t<a class=\"timeline-banner hidden-text\" href=\"/users/{nickname}/tlfeatures\">"
|
||||||
|
f"{translate['Features']}</a>\n"
|
||||||
|
f"\t<div class=\"title\">\n"
|
||||||
|
f"\t\t<span>#IndymediaBack</span>\n"
|
||||||
|
f"\t</div>\n")
|
||||||
|
|
||||||
|
# Certain Epciyon pages should only be accessible via the 'User' page for News instances
|
||||||
|
# TODO: Better solution - Currently this is a duplicate of list created in 'webapp_timeline.py'
|
||||||
|
userPages = ['inbox', 'outbox', 'dm', 'tlreplies', 'tlblogs', 'tlmedia', 'tlshares', \
|
||||||
|
'tlsaves', 'tlevents', 'tlbookmarks', 'moderation', 'search', \
|
||||||
|
'followers', 'newfollowers', 'newdm', 'newpost', 'newblog', 'newevent']
|
||||||
|
|
||||||
|
# Full row "navbar"
|
||||||
|
if defaultTimeline == 'tlfeatures':
|
||||||
|
# Show "tab" links instead of standard "buttons"
|
||||||
|
# NOTE: "inbox" is used as a generic boxName, as with 'User' pages
|
||||||
|
newPostForm += headerNewsTabs('inbox', translate, usersPath, baseDir, userPages)
|
||||||
|
|
||||||
|
# Close banner div
|
||||||
|
newPostForm += '</div>\n'
|
||||||
|
|
||||||
mentionsStr = ''
|
mentionsStr = ''
|
||||||
for m in mentions:
|
for m in mentions:
|
||||||
|
|
@ -638,6 +676,24 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
# reporting a post to moderator
|
# reporting a post to moderator
|
||||||
mentionsStr = 'Re: ' + reportUrl + '\n\n' + mentionsStr
|
mentionsStr = 'Re: ' + reportUrl + '\n\n' + mentionsStr
|
||||||
|
|
||||||
|
# TODO: Place form inside a "page" div for 'News' instances
|
||||||
|
newPostForm += '<div class="page">\n'
|
||||||
|
|
||||||
|
moderator = isModerator(baseDir, nickname)
|
||||||
|
|
||||||
|
# TODO: Add "User" links
|
||||||
|
if defaultTimeline == 'tlfeatures':
|
||||||
|
# NOTE: It appears that 'endpoint' is effectively 'boxName'
|
||||||
|
newPostForm += \
|
||||||
|
headerButtonsTimeline(defaultTimeline, endpoint, pageNumber,
|
||||||
|
translate, usersPath,
|
||||||
|
False, moderator,
|
||||||
|
False,
|
||||||
|
baseDir, nickname,
|
||||||
|
domain, None,
|
||||||
|
True, userPages)
|
||||||
|
newPostForm += '<div class="section main">\n'
|
||||||
|
|
||||||
newPostForm += \
|
newPostForm += \
|
||||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||||
'accept-charset="UTF-8" action="' + \
|
'accept-charset="UTF-8" action="' + \
|
||||||
|
|
@ -742,6 +798,9 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
|
||||||
newPostForm += ' </div>\n'
|
newPostForm += ' </div>\n'
|
||||||
newPostForm += '</form>\n'
|
newPostForm += '</form>\n'
|
||||||
|
|
||||||
|
# Close "section" and "page" div
|
||||||
|
newPostForm += '</div><!-- div main -->\n</div><!-- div page -->\n'
|
||||||
|
|
||||||
if not reportUrl:
|
if not reportUrl:
|
||||||
newPostForm = \
|
newPostForm = \
|
||||||
newPostForm.replace('<body>', '<body onload="focusOnMessage()">')
|
newPostForm.replace('<body>', '<body onload="focusOnMessage()">')
|
||||||
|
|
|
||||||
|
|
@ -352,9 +352,10 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
navIconStr += '\t\t\t</ul>\n\t\t</div>\n'
|
navIconStr += '\t\t\t</ul>\n\t\t</div>\n'
|
||||||
|
|
||||||
# benchmark 5
|
# benchmark 5
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
if timelineStartTime:
|
||||||
if timeDiff > 100:
|
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
||||||
print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff))
|
if timeDiff > 100:
|
||||||
|
print('TIMELINE TIMING ' + boxName + ' 5 = ' + str(timeDiff))
|
||||||
|
|
||||||
|
|
||||||
# Compile HTML parts
|
# Compile HTML parts
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
# Close banner div
|
# Close banner div
|
||||||
tlStr += '</div>\n'
|
tlStr += '</div>\n'
|
||||||
|
|
||||||
|
# TODO: Should probably use a more generic class, easier to re-use and help simplify CSS
|
||||||
|
# NOTE: Related also to class "page" added to 'webapp_create_post.py'
|
||||||
# start the timeline
|
# start the timeline
|
||||||
tlStr += '<div class="timeline">\n'
|
tlStr += '<div class="timeline">\n'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue