aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2021-04-12 17:55:16 -0400
committerMicah Lee <micah@micahflee.com>2021-04-12 17:55:16 -0400
commitb5c68fa5ca63b6a592ac2cfb75179a83222d55ac (patch)
treed7c8db3bd6de2fc33f4dac4cea260d7143f92792 /cli
parent530f9547f5ac28e68e83ed827d334f66de99bdc4 (diff)
downloadonionshare-b5c68fa5ca63b6a592ac2cfb75179a83222d55ac.tar.gz
onionshare-b5c68fa5ca63b6a592ac2cfb75179a83222d55ac.zip
Add --title, and make it display the title in chat mode
Diffstat (limited to 'cli')
-rw-r--r--cli/onionshare_cli/__init__.py8
-rw-r--r--cli/onionshare_cli/mode_settings.py1
-rw-r--r--cli/onionshare_cli/resources/templates/chat.html4
-rw-r--r--cli/onionshare_cli/web/chat_mode.py8
4 files changed, 13 insertions, 8 deletions
diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py
index 1bd0582c..9e530c6c 100644
--- a/cli/onionshare_cli/__init__.py
+++ b/cli/onionshare_cli/__init__.py
@@ -144,6 +144,12 @@ def main(cwd=None):
)
# General args
parser.add_argument(
+ "--title",
+ metavar="TITLE",
+ default=None,
+ help="Set a title",
+ )
+ parser.add_argument(
"--public",
action="store_true",
dest="public",
@@ -234,6 +240,7 @@ def main(cwd=None):
connect_timeout = int(args.connect_timeout)
config_filename = args.config
persistent_filename = args.persistent
+ title = args.title
public = bool(args.public)
autostart_timer = int(args.autostart_timer)
autostop_timer = int(args.autostop_timer)
@@ -280,6 +287,7 @@ def main(cwd=None):
if mode_settings.just_created:
# This means the mode settings were just created, not loaded from disk
+ mode_settings.set("general", "title", title)
mode_settings.set("general", "public", public)
mode_settings.set("general", "autostart_timer", autostart_timer)
mode_settings.set("general", "autostop_timer", autostop_timer)
diff --git a/cli/onionshare_cli/mode_settings.py b/cli/onionshare_cli/mode_settings.py
index c2e5e6cd..9ebf8e61 100644
--- a/cli/onionshare_cli/mode_settings.py
+++ b/cli/onionshare_cli/mode_settings.py
@@ -42,6 +42,7 @@ class ModeSettings:
},
"persistent": {"mode": None, "enabled": False},
"general": {
+ "title": None,
"public": False,
"autostart_timer": False,
"autostop_timer": False,
diff --git a/cli/onionshare_cli/resources/templates/chat.html b/cli/onionshare_cli/resources/templates/chat.html
index b4443c09..7156d58c 100644
--- a/cli/onionshare_cli/resources/templates/chat.html
+++ b/cli/onionshare_cli/resources/templates/chat.html
@@ -2,7 +2,7 @@
<html>
<head>
- <title>OnionShare</title>
+ <title>{% if title %}{{ title }}{% else %}OnionShare Chat{% endif %}</title>
<link href="{{ static_url_path }}/img/favicon.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" rel="subresource" type="text/css" href="{{ static_url_path }}/css/style.css" media="all">
</head>
@@ -11,7 +11,7 @@
<header class="clearfix">
<img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
- <h1>OnionShare</h1>
+ <h1>{% if title %}{{ title }}{% else %}OnionShare Chat{% endif %}</h1>
</header>
<noscript>
<p>
diff --git a/cli/onionshare_cli/web/chat_mode.py b/cli/onionshare_cli/web/chat_mode.py
index 2daf9654..8b2a5673 100644
--- a/cli/onionshare_cli/web/chat_mode.py
+++ b/cli/onionshare_cli/web/chat_mode.py
@@ -18,12 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-from flask import (
- request,
- render_template,
- make_response,
- jsonify,
- session)
+from flask import request, render_template, make_response, jsonify, session
from flask_socketio import emit, join_room, leave_room
@@ -72,6 +67,7 @@ class ChatModeWeb:
"chat.html",
static_url_path=self.web.static_url_path,
username=session.get("name"),
+ title=self.web.settings.get("general", "title"),
)
)
return self.web.add_security_headers(r)