forked from whisperchan/cursedboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursedboard.py
60 lines (52 loc) · 1.69 KB
/
cursedboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import npyscreen
import session
import curses
import sys
from config import *
from database import Database
from thread_view import ThreadView
from frontpage import Frontpage
from board_view import BoardView
from post_form import PostForm
from file_browser import FileBrowser, TextViewer, DeleteFileForm
from image_viewer import ImageViewer
class TestApp(npyscreen.NPSAppManaged):
def onStart(self):
self.admin = False
self.myDatabase = Database(filename=DATABASE_FILE)
self.myBoardId = 0
self.myThreadId = 0
self.myThreadTitle = ""
self.myThreadContent = ""
self.myPath = ""
self.addForm("MAIN", Frontpage)
self.addForm("BOARD", BoardView)
self.addForm("POST", PostForm)
self.addForm("THREAD", ThreadView)
self.addForm("FILES", FileBrowser)
self.addForm("TEXTVIEWER", TextViewer)
self.addForm("IMGVIEWER", ImageViewer)
self.addForm("DELETEFILE", DeleteFileForm)
# Disable mouse, easier copy / paste
curses.mousemask(0)
def deauthenticate(self):
self.admin = False
def authenticate(self, pw):
self.admin = False
if pw == PASSWORD:
self.admin = True
def authenticated(self):
return self.admin
if __name__ == "__main__":
try:
if len(sys.argv) == 2:
session.parse_session(sys.argv[1])
App = TestApp()
App.run()
except npyscreen.wgwidget.NotEnoughSpaceForWidget:
print("Please increase the size of your terminal and reconnect")
print("Press any key to close connection")
input()
except KeyboardInterrupt:
print("Good bye")