From 0c3ec272b1237e66733dfa858811a0cd40eb1c86 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 12 Oct 2020 20:41:53 +0100 Subject: [PATCH] Mobile links screen --- daemon.py | 24 ++++++++++++--- epicyon-profile.css | 12 ++++++++ webinterface.py | 72 ++++++++++++++++++++++++++++++--------------- 3 files changed, 80 insertions(+), 28 deletions(-) diff --git a/daemon.py b/daemon.py index 4b0ae2af3..c5a815729 100644 --- a/daemon.py +++ b/daemon.py @@ -143,6 +143,7 @@ from webinterface import htmlFollowConfirm from webinterface import htmlCalendar from webinterface import htmlSearch from webinterface import htmlNewswireMobile +from webinterface import htmlLinksMobile from webinterface import htmlSearchEmoji from webinterface import htmlSearchEmojiTextEntry from webinterface import htmlUnfollowConfirm @@ -9083,19 +9084,15 @@ class PubServer(BaseHTTPRequestHandler): 'permitted directory', 'login shown done') - print('TEST1 ' + self.path) if authorized and htmlGET and '/users/' in self.path and \ self.path.endswith('/newswiremobile'): - print('TEST2 ' + self.path) nickname = getNicknameFromActor(self.path) if not nickname: self._404() self.server.GETbusy = False return - print('TEST3 ' + nickname) timelinePath = \ '/users/' + nickname + '/' + self.server.defaultTimeline - print('TEST4 ' + timelinePath) msg = htmlNewswireMobile(self.server.baseDir, nickname, self.server.domain, @@ -9110,6 +9107,25 @@ class PubServer(BaseHTTPRequestHandler): self.server.GETbusy = False return + if authorized and htmlGET and '/users/' in self.path and \ + self.path.endswith('/linksmobile'): + nickname = getNicknameFromActor(self.path) + if not nickname: + self._404() + self.server.GETbusy = False + return + timelinePath = \ + '/users/' + nickname + '/' + self.server.defaultTimeline + msg = htmlLinksMobile(self.server.baseDir, nickname, + self.server.domainFull, + self.server.httpPrefix, + self.server.translate, + timelinePath).encode('utf-8') + self._set_headers('text/html', len(msg), cookie, callingDomain) + self._write(msg) + self.server.GETbusy = False + return + # hashtag search if self.path.startswith('/tags/') or \ (authorized and '/tags/' in self.path): diff --git a/epicyon-profile.css b/epicyon-profile.css index cccbdf5b2..71f57ded7 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -1541,12 +1541,24 @@ aside .toggle-inside li { font-size: var(--font-size); line-height: var(--line-spacing); } + .leftColEditImage { + background: var(--main-bg-color); + width: var(--column-left-icon-size); + float: right; + margin: 20px 0px; + } .rightColEditImage { background: var(--main-bg-color); width: var(--column-right-icon-size); float: right; margin: 20px 0px; } + .leftColImg { + background: var(--main-bg-color); + width: 100vw; + margin: 0 0; + padding: 0 0; + } .rightColImg { background: var(--main-bg-color); width: 100vw; diff --git a/webinterface.py b/webinterface.py index 510056e26..0a116ee61 100644 --- a/webinterface.py +++ b/webinterface.py @@ -5381,7 +5381,8 @@ def htmlHighlightLabel(label: str, highlight: bool) -> str: def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, httpPrefix: str, translate: {}, - iconsDir: str, editor: bool) -> str: + iconsDir: str, editor: bool, + showBackButton: bool, timelinePath: str) -> str: """Returns html content for the left column """ htmlStr = '' @@ -5414,6 +5415,12 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, nickname + '/left_col_image.png" />\n' + \ ' \n' + if showBackButton: + htmlStr += \ + ' ' + \ + '\n' + if editImageClass == 'leftColEdit': htmlStr += '\n
\n' @@ -5659,6 +5666,43 @@ def getRightColumnContent(baseDir: str, nickname: str, domainFull: str, return htmlStr +def htmlLinksMobile(baseDir: str, nickname: str, domainFull: str, + httpPrefix: str, translate, + timelinePath: str) -> str: + """Show the left column links within mobile view + """ + htmlStr = '' + + # the css filename + cssFilename = baseDir + '/epicyon-profile.css' + if os.path.isfile(baseDir + '/epicyon.css'): + cssFilename = baseDir + '/epicyon.css' + + profileStyle = None + with open(cssFilename, 'r') as cssFile: + # load css + profileStyle = \ + cssFile.read() + # replace any https within the css with whatever prefix is needed + if httpPrefix != 'https': + profileStyle = \ + profileStyle.replace('https://', httpPrefix + '://') + + iconsDir = getIconsDir(baseDir) + + # is the user a site editor? + editor = isEditor(baseDir, nickname) + + htmlStr = htmlHeader(cssFilename, profileStyle) + htmlStr += \ + getLeftColumnContent(baseDir, nickname, domainFull, + httpPrefix, translate, + iconsDir, editor, + True, timelinePath) + htmlStr += htmlFooter() + return htmlStr + + def htmlNewswireMobile(baseDir: str, nickname: str, domain: str, domainFull: str, httpPrefix: str, translate: {}, @@ -5674,31 +5718,11 @@ def htmlNewswireMobile(baseDir: str, nickname: str, if os.path.isfile(baseDir + '/epicyon.css'): cssFilename = baseDir + '/epicyon.css' - # filename of the banner shown at the top - bannerFile = 'banner.png' - bannerFilename = baseDir + '/accounts/' + \ - nickname + '@' + domain + '/' + bannerFile - if not os.path.isfile(bannerFilename): - bannerFile = 'banner.jpg' - bannerFilename = baseDir + '/accounts/' + \ - nickname + '@' + domain + '/' + bannerFile - if not os.path.isfile(bannerFilename): - bannerFile = 'banner.gif' - bannerFilename = baseDir + '/accounts/' + \ - nickname + '@' + domain + '/' + bannerFile - if not os.path.isfile(bannerFilename): - bannerFile = 'banner.avif' - bannerFilename = baseDir + '/accounts/' + \ - nickname + '@' + domain + '/' + bannerFile - if not os.path.isfile(bannerFilename): - bannerFile = 'banner.webp' - profileStyle = None with open(cssFilename, 'r') as cssFile: # load css profileStyle = \ - cssFile.read().replace('banner.png', - '/users/' + nickname + '/' + bannerFile) + cssFile.read() # replace any https within the css with whatever prefix is needed if httpPrefix != 'https': profileStyle = \ @@ -6047,7 +6071,7 @@ def htmlTimeline(defaultTimeline: str, leftColumnStr = \ getLeftColumnContent(baseDir, nickname, domainFull, httpPrefix, translate, iconsDir, - editor) + editor, False, None) tlStr += ' ' + \ leftColumnStr + ' \n' # center column containing posts @@ -6222,7 +6246,7 @@ def htmlTimeline(defaultTimeline: str, # the links button to show left column links tlStr += \ ' ' + \ + usersPath + '/linksmobile">' + \ '