New post scope

master
Bob Mottram 2019-07-26 13:26:41 +01:00
parent 96ef34eb77
commit 1c8ab532bc
3 changed files with 72 additions and 30 deletions

View File

@ -383,7 +383,9 @@ class PubServer(BaseHTTPRequestHandler):
# if not authorized then show the login screen
if self.headers.get('Accept'):
if 'text/html' in self.headers['Accept'] and self.path!='/login':
if '/media/' not in self.path and 'sharefiles' not in self.path:
if '/media/' not in self.path and \
'/sharefiles/' not in self.path and \
'/icons/' not in self.path:
if not authorized:
self.send_response(303)
self.send_header('Location', '/login')
@ -466,7 +468,7 @@ class PubServer(BaseHTTPRequestHandler):
return
# icon images
# Note that this comes before the busy flag to avoid conflicts
if '/icons/' in self.path:
if self.path.startswith('/icons/'):
if self.path.endswith('.png'):
mediaStr=self.path.split('/icons/')[1]
mediaFilename= \
@ -538,7 +540,12 @@ class PubServer(BaseHTTPRequestHandler):
self.server.GETbusy=False
return
if '/users/' in self.path and self.path.endswith('/newpost'):
if '/users/' in self.path and \
(self.path.endswith('/newpost') or \
self.path.endswith('/newunlisted') or \
self.path.endswith('/newfollowers') or \
self.path.endswith('/newdm') or \
self.path.endswith('/newshare')):
self._login_headers('text/html')
self.wfile.write(htmlNewPost(self.server.baseDir,self.path).encode('utf-8'))
self.server.GETbusy=False

View File

@ -264,37 +264,51 @@ input[type=submit]:hover {
}
.dropbtn {
background-color: #555;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 18px;
opacity: 1.0;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
padding: 0px 14px;
position: relative;
display: inline-block;
}
.dropdown img {
opacity: 1.0;
width: 24px;
height: 24px;
padding: 0px 16px;
-ms-transform: translateY(-10%);
transform: translateY(-10%);
}
.scope-desc {
font-size: 18px;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 260px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 300px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content img {
width: 24px;
height: 24px;
padding: 0px 0px;
}
/* Change color of dropdown links on hover */

View File

@ -83,26 +83,47 @@ def htmlNewPost(baseDir: str,path: str) -> str:
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
newPostCSS = cssFile.read()
pathBase=path.replace('/newpost','').replace('/newshare','').replace('/newunlisted','').replace('/newfollowers','').replace('/newdm','')
scopeIcon='scope_public.png'
scopeDescription='Public'
placeholderSubject='Subject or Content Warning (optional)...'
placeholderMessage='Write something...'
if path.endswith('/newunlisted'):
scopeIcon='scope_unlisted.png'
scopeDescription='Unlisted'
if path.endswith('/newfollowers'):
scopeIcon='scope_followers.png'
scopeDescription='Followers Only'
if path.endswith('/newdm'):
scopeIcon='scope_dm.png'
scopeDescription='Direct Message'
if path.endswith('/newshare'):
scopeIcon='scope_share.png'
scopeDescription='Shared Item'
placeholderSubject='Name of the shared item...'
placeholderMessage='Description of the item being shared...'
newPostForm=htmlHeader(newPostCSS)
newPostForm+= \
'<form method="POST" action="'+path+'?newpost">' \
' <div class="vertical-center">' \
' <label for="nickname"><b>'+newPostText+'</b></label>' \
' <input type="text" placeholder="Subject or Content Warning (optional)..." name="subject">' \
' <input type="text" placeholder="'+placeholderSubject+'" name="subject">' \
'' \
' <textarea id="message" name="message" placeholder="Write something..." style="height:200px"></textarea>' \
' <textarea id="message" name="message" placeholder="'+placeholderMessage+'" style="height:200px"></textarea>' \
'' \
' <div class="container">' \
' <input type="submit" value="Cancel">' \
' <input type="submit" value="Submit">' \
' <div class="dropdown">' \
' <button class="dropbtn">Scope</button>' \
' <img src="/icons/'+scopeIcon+'"/><b class="scope-desc">'+scopeDescription+'</b>' \
' <div class="dropdown-content">' \
' <a href="#"><img="/icons/scope_public.png"/><b>Public</b><br>Visible to anyone</a>' \
' <a href="#"><img="/icons/scope_unlisted.png"/><b>Unlisted</b><br>Not shown on public timeline</a>' \
' <a href="#"><img="/icons/scope_followers.png"/><b>Followers Only</b><br>Only sent to followers</a>' \
' <a href="#"><img="/icons/scope_dm.png"/><b>Direct Message</b><br>Sent only to mentioned people</a>' \
' <a href="#"><img="/icons/scope_offer.png"/><b>Offer</b><br>Describe a shared item</a>' \
' <a href="'+pathBase+'/newpost"><img src="/icons/scope_public.png"/><b>Public</b><br>Visible to anyone</a>' \
' <a href="'+pathBase+'/newunlisted"><img src="/icons/scope_unlisted.png"/><b>Unlisted</b><br>Not on public timeline</a>' \
' <a href="'+pathBase+'/newfollowers"><img src="/icons/scope_followers.png"/><b>Followers Only</b><br>Only to followers</a>' \
' <a href="'+pathBase+'/newdm"><img src="/icons/scope_dm.png"/><b>Direct Message</b><br>Only to mentioned people</a>' \
' <a href="'+pathBase+'/newshare"><img src="/icons/scope_share.png"/><b>Share</b><br>Describe a shared item</a>' \
' </div>' \
' </div>' \
' </div>' \