aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
authordesvox <ofunknowndescent@gmail.com>2018-08-05 22:25:02 -0500
committerdesvox <ofunknowndescent@gmail.com>2018-08-05 22:25:02 -0500
commit1c296cc500e507008b9a7a0ffb06b0dc26202a1a (patch)
tree6b2bdd636b40df089130cdbccffeff153e9285a5 /clients
parentcba92412a82f0737cf2517412fabb825ed133ccb (diff)
downloadbbj-1c296cc500e507008b9a7a0ffb06b0dc26202a1a.tar.gz
Allow admins to set server pins from client.
Diffstat (limited to 'clients')
-rw-r--r--clients/network_client.py5
-rw-r--r--clients/urwid/main.py27
2 files changed, 23 insertions, 9 deletions
diff --git a/clients/network_client.py b/clients/network_client.py
index 3a2ca3d..6cd4883 100644
--- a/clients/network_client.py
+++ b/clients/network_client.py
@@ -592,15 +592,14 @@ class BBJ(object):
return response["data"]
- def set_thread_pin(self, thread_id, new_status):
+ def thread_set_pin(self, thread_id, new_status):
"""
Set whether a thread should be pinned or not. new_status
is evaluated as a boolean, and given that the logged in
user is an admin, the thread is set to this status on
the server, and the boolean is returned.
"""
- assert self.get_me()["is_admin"]
- response = self("set_thread_pin", thread_id=pinned, pinned=new_status)
+ response = self("thread_set_pin", thread_id=thread_id, value=new_status)
return response["data"]
diff --git a/clients/urwid/main.py b/clients/urwid/main.py
index 06bae27..d95b505 100644
--- a/clients/urwid/main.py
+++ b/clients/urwid/main.py
@@ -668,6 +668,8 @@ class App(object):
"Enable Formatting" if raw else "Disable Formatting",
self.toggle_formatting, message))
buttons.insert(0, urwid.Button("Edit Post", self.edit_post, message))
+ if network.user["is_admin"]:
+ buttons.insert(0, urwid.Text(("20", "Reminder: You're an admin!")))
if not buttons:
return
@@ -823,19 +825,22 @@ class App(object):
self.usermap.update(usermap)
self.walker.clear()
- server_pin_counter = 0
+ server_pins = []
client_pin_counter = 0
for thread in threads:
if thread["pinned"]:
- self.walker.insert(server_pin_counter, self.make_thread_body(thread, pinned="server"))
- server_pin_counter += 1
+ server_pins.append(thread)
elif thread["thread_id"] in self.client_pinned_threads:
self.walker.insert(client_pin_counter, self.make_thread_body(thread, pinned="client"))
client_pin_counter += 1
else:
self.walker.append(self.make_thread_body(thread))
+ # make sure these are always up top
+ for index, thread in enumerate(server_pins):
+ self.walker.insert(index, self.make_thread_body(thread, pinned="server"))
+
self.set_bars(True)
if self.last_index_pos:
@@ -882,6 +887,14 @@ class App(object):
self.index()
+ def toggle_server_pin(self):
+ if self.mode != "index" or not network.user["is_admin"]:
+ return
+ thread = self.walker.get_focus()[0].thread
+ network.thread_set_pin(thread["thread_id"], not thread["pinned"])
+ self.index()
+
+
def search_index_callback(self, query):
simple_query = query.lower().strip()
threads, usermap = network.thread_index()
@@ -2233,6 +2246,9 @@ class ActionBox(urwid.ListBox):
elif key == "*":
app.toggle_client_pin()
+ elif key == "\\":
+ app.toggle_server_pin()
+
elif key == "~":
# sssssshhhhhhhh
app.loop.stop()
@@ -2240,13 +2256,12 @@ class ActionBox(urwid.ListBox):
except: pass
app.loop.start()
- elif keyl == "f12":
+ elif keyl == "$":
app.loop.stop()
call("clear", shell=True)
- motherfucking_rainbows(obnoxious_logo)
readline.set_completer(rlcompleter.Completer().complete)
readline.parse_and_bind("tab: complete")
- interact(banner=version + "\n(BBJ Interactive Console)", local=globals())
+ interact(banner="Python " + version + "\nBBJ Interactive Console\nCtrl-D exits.", local=globals())
app.loop.start()
elif app.mode == "thread" and not app.window_split and not overlay:
Un proyecto texto-plano.xyz