forked from indymedia/epicyon
				
			Cancel button on new post screen
							parent
							
								
									f81ca9d66d
								
							
						
					
					
						commit
						f4222bd4f4
					
				
							
								
								
									
										77
									
								
								daemon.py
								
								
								
								
							
							
						
						
									
										77
									
								
								daemon.py
								
								
								
								
							|  | @ -1065,6 +1065,10 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|         self._set_headers('application/json',None) |         self._set_headers('application/json',None) | ||||||
| 
 | 
 | ||||||
|     def _receiveNewPost(self,authorized: bool,postType: str) -> bool: |     def _receiveNewPost(self,authorized: bool,postType: str) -> bool: | ||||||
|  |         # 0 = this is not a new post | ||||||
|  |         # 1 = new post success | ||||||
|  |         # -1 = new post failed | ||||||
|  |         # 2 = new post canceled | ||||||
|         if authorized and '/users/' in self.path and self.path.endswith('?'+postType):             |         if authorized and '/users/' in self.path and self.path.endswith('?'+postType):             | ||||||
|             if ' boundary=' in self.headers['Content-type']: |             if ' boundary=' in self.headers['Content-type']: | ||||||
|                 nickname=None |                 nickname=None | ||||||
|  | @ -1072,11 +1076,11 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                 if '/' in nicknameStr: |                 if '/' in nicknameStr: | ||||||
|                     nickname=nicknameStr.split('/')[0] |                     nickname=nicknameStr.split('/')[0] | ||||||
|                 else: |                 else: | ||||||
|                     return False |                     return -1 | ||||||
|                 length = int(self.headers['Content-length']) |                 length = int(self.headers['Content-length']) | ||||||
|                 if length>self.server.maxPostLength: |                 if length>self.server.maxPostLength: | ||||||
|                     print('POST size too large') |                     print('POST size too large') | ||||||
|                     return False |                     return -1 | ||||||
| 
 | 
 | ||||||
|                 boundary=self.headers['Content-type'].split('boundary=')[1] |                 boundary=self.headers['Content-type'].split('boundary=')[1] | ||||||
|                 if ';' in boundary: |                 if ';' in boundary: | ||||||
|  | @ -1146,7 +1150,12 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                 # send the post |                 # send the post | ||||||
| 
 | 
 | ||||||
|                 if not fields.get('message'): |                 if not fields.get('message'): | ||||||
|                     return False |                     return -1 | ||||||
|  |                 if fields.get('submitPost'): | ||||||
|  |                     if fields['submitPost']!='Submit': | ||||||
|  |                         return -1 | ||||||
|  |                 else: | ||||||
|  |                     return 2 | ||||||
| 
 | 
 | ||||||
|                 if not fields.get('imageDescription'): |                 if not fields.get('imageDescription'): | ||||||
|                     fields['imageDescription']=None |                     fields['imageDescription']=None | ||||||
|  | @ -1166,7 +1175,10 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                                          fields['replyTo'], fields['replyTo'],fields['subject']) |                                          fields['replyTo'], fields['replyTo'],fields['subject']) | ||||||
|                     if messageJson: |                     if messageJson: | ||||||
|                         self.postToNickname=nickname |                         self.postToNickname=nickname | ||||||
|                         return self._postToOutbox(messageJson) |                         if self._postToOutbox(messageJson): | ||||||
|  |                             return 1 | ||||||
|  |                         else: | ||||||
|  |                             return -1 | ||||||
| 
 | 
 | ||||||
|                 if postType=='newunlisted': |                 if postType=='newunlisted': | ||||||
|                     messageJson= \ |                     messageJson= \ | ||||||
|  | @ -1179,7 +1191,10 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                                            fields['replyTo'], fields['replyTo'],fields['subject']) |                                            fields['replyTo'], fields['replyTo'],fields['subject']) | ||||||
|                     if messageJson: |                     if messageJson: | ||||||
|                         self.postToNickname=nickname |                         self.postToNickname=nickname | ||||||
|                         return self._postToOutbox(messageJson) |                         if self._postToOutbox(messageJson): | ||||||
|  |                             return 1 | ||||||
|  |                         else: | ||||||
|  |                             return -1 | ||||||
| 
 | 
 | ||||||
|                 if postType=='newfollowers': |                 if postType=='newfollowers': | ||||||
|                     messageJson= \ |                     messageJson= \ | ||||||
|  | @ -1192,7 +1207,10 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                                                 fields['replyTo'], fields['replyTo'],fields['subject']) |                                                 fields['replyTo'], fields['replyTo'],fields['subject']) | ||||||
|                     if messageJson: |                     if messageJson: | ||||||
|                         self.postToNickname=nickname |                         self.postToNickname=nickname | ||||||
|                         return self._postToOutbox(messageJson) |                         if self._postToOutbox(messageJson): | ||||||
|  |                             return 1 | ||||||
|  |                         else: | ||||||
|  |                             return -1 | ||||||
| 
 | 
 | ||||||
|                 if postType=='newdm': |                 if postType=='newdm': | ||||||
|                     messageJson= \ |                     messageJson= \ | ||||||
|  | @ -1205,7 +1223,10 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                                                 fields['replyTo'],fields['replyTo'],fields['subject']) |                                                 fields['replyTo'],fields['replyTo'],fields['subject']) | ||||||
|                     if messageJson: |                     if messageJson: | ||||||
|                         self.postToNickname=nickname |                         self.postToNickname=nickname | ||||||
|                         return self._postToOutbox(messageJson) |                         if self._postToOutbox(messageJson): | ||||||
|  |                             return 1 | ||||||
|  |                         else: | ||||||
|  |                             return -1 | ||||||
| 
 | 
 | ||||||
|                 if postType=='newshare': |                 if postType=='newshare': | ||||||
|                     if not fields.get('itemType'): |                     if not fields.get('itemType'): | ||||||
|  | @ -1231,8 +1252,13 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                     if os.path.isfile(filename): |                     if os.path.isfile(filename): | ||||||
|                         os.remove(filename) |                         os.remove(filename) | ||||||
|                     self.postToNickname=nickname |                     self.postToNickname=nickname | ||||||
|                     return self._postToOutbox(messageJson) |                     if self._postToOutbox(messageJson): | ||||||
|         return False |                         return 1 | ||||||
|  |                     else: | ||||||
|  |                         return -1 | ||||||
|  |             return -1 | ||||||
|  |         else: | ||||||
|  |             return 0 | ||||||
|          |          | ||||||
|     def do_POST(self): |     def do_POST(self): | ||||||
|         if self.server.debug: |         if self.server.debug: | ||||||
|  | @ -1323,23 +1349,40 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|             self.server.POSTbusy=False |             self.server.POSTbusy=False | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         if self._receiveNewPost(authorized,'newpost'): |         postState=self._receiveNewPost(authorized,'newpost') | ||||||
|  |         if postState!=0: | ||||||
|  |             nickname=self.path.split('/users/')[1] | ||||||
|  |             if '/' in nickname: | ||||||
|  |                 nickname=nickname.split('/')[0] | ||||||
|  |             self._redirect_headers('/users/'+nickname+'/outbox') | ||||||
|  |             self.server.POSTbusy=False | ||||||
|  |             return | ||||||
|  |         postState=self._receiveNewPost(authorized,'newunlisted') | ||||||
|  |         if postState!=0: | ||||||
|  |             nickname=self.path.split('/users/')[1] | ||||||
|  |             if '/' in nickname: | ||||||
|  |                 nickname=nickname.split('/')[0] | ||||||
|             self._redirect_headers('/users/'+self.postToNickname+'/outbox') |             self._redirect_headers('/users/'+self.postToNickname+'/outbox') | ||||||
|             self.server.POSTbusy=False |             self.server.POSTbusy=False | ||||||
|             return |             return | ||||||
|         elif self._receiveNewPost(authorized,'newunlisted'): |         postState=self._receiveNewPost(authorized,'newfollowers') | ||||||
|  |         if postState!=0: | ||||||
|  |             if '/' in nickname: | ||||||
|  |                 nickname=nickname.split('/')[0] | ||||||
|             self._redirect_headers('/users/'+self.postToNickname+'/outbox') |             self._redirect_headers('/users/'+self.postToNickname+'/outbox') | ||||||
|             self.server.POSTbusy=False |             self.server.POSTbusy=False | ||||||
|             return |             return | ||||||
|         elif self._receiveNewPost(authorized,'newfollowers'): |         postState=self._receiveNewPost(authorized,'newdm') | ||||||
|  |         if postState!=0: | ||||||
|  |             if '/' in nickname: | ||||||
|  |                 nickname=nickname.split('/')[0] | ||||||
|             self._redirect_headers('/users/'+self.postToNickname+'/outbox') |             self._redirect_headers('/users/'+self.postToNickname+'/outbox') | ||||||
|             self.server.POSTbusy=False |             self.server.POSTbusy=False | ||||||
|             return |             return | ||||||
|         elif self._receiveNewPost(authorized,'newdm'): |         postState=self._receiveNewPost(authorized,'newshare') | ||||||
|             self._redirect_headers('/users/'+self.postToNickname+'/outbox') |         if postState!=0: | ||||||
|             self.server.POSTbusy=False |             if '/' in nickname: | ||||||
|             return |                 nickname=nickname.split('/')[0] | ||||||
|         elif self._receiveNewPost(authorized,'newshare'): |  | ||||||
|             self._redirect_headers('/users/'+self.postToNickname+'/shares') |             self._redirect_headers('/users/'+self.postToNickname+'/shares') | ||||||
|             self.server.POSTbusy=False |             self.server.POSTbusy=False | ||||||
|             return |             return | ||||||
|  |  | ||||||
|  | @ -268,6 +268,18 @@ input[type=submit] { | ||||||
|     font-size: 18px; |     font-size: 18px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .cancelbtn { | ||||||
|  |     background-color: #555; | ||||||
|  |     color: white; | ||||||
|  |     float: right; | ||||||
|  |     margin: 0px 10px; | ||||||
|  |     padding: 12px 40px; | ||||||
|  |     border: none; | ||||||
|  |     border-radius: 4px; | ||||||
|  |     cursor: pointer; | ||||||
|  |     font-size: 18px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| input[type=file] { | input[type=file] { | ||||||
|     background-color: #555; |     background-color: #555; | ||||||
|     color: white; |     color: white; | ||||||
|  |  | ||||||
|  | @ -137,8 +137,8 @@ def htmlNewPost(baseDir: str,path: str) -> str: | ||||||
|         '          <a href="'+pathBase+'/newshare"><img src="/icons/scope_share.png"/><b>Share</b><br>Describe a shared item</a>' \ |         '          <a href="'+pathBase+'/newshare"><img src="/icons/scope_share.png"/><b>Share</b><br>Describe a shared item</a>' \ | ||||||
|         '        </div>' \ |         '        </div>' \ | ||||||
|         '      </div>' \ |         '      </div>' \ | ||||||
|         '      <input type="submit" value="Submit">' \ |         '      <input type="submit" name="submitPost" value="Submit">' \ | ||||||
|         '      <input type="submit" value="Cancel">' \ |         '      <a href="'+pathBase+'/outbox"><button class="cancelbtn">Cancel</button></a>' \ | ||||||
|         '    </div>' \ |         '    </div>' \ | ||||||
|         '    <input type="text" placeholder="'+placeholderSubject+'" name="subject">' \ |         '    <input type="text" placeholder="'+placeholderSubject+'" name="subject">' \ | ||||||
|         '' \ |         '' \ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue