aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorSaptak Sengupta <saptak013@gmail.com>2021-04-28 14:43:10 +0530
committerGitHub <noreply@github.com>2021-04-28 14:43:10 +0530
commit059a4425bd655337b04c6835424c7ae84425f8b6 (patch)
tree4a876438289fc4183749cb4e6bec7cf9879cae0b /cli
parent470fb2bda3a04c856256191ceee267ce94515eef (diff)
parente48878e55813200206a6939f7c50d0710b0504f9 (diff)
downloadonionshare-059a4425bd655337b04c6835424c7ae84425f8b6.tar.gz
onionshare-059a4425bd655337b04c6835424c7ae84425f8b6.zip
Merge pull request #1327 from micahflee/1306_customization
Allow custom title for each onion service
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/resources/templates/listing.html6
-rw-r--r--cli/onionshare_cli/resources/templates/receive.html87
-rw-r--r--cli/onionshare_cli/resources/templates/send.html17
-rw-r--r--cli/onionshare_cli/resources/templates/thankyou.html6
-rw-r--r--cli/onionshare_cli/web/chat_mode.py8
-rw-r--r--cli/onionshare_cli/web/receive_mode.py6
-rw-r--r--cli/onionshare_cli/web/share_mode.py1
-rw-r--r--cli/onionshare_cli/web/website_mode.py1
11 files changed, 80 insertions, 65 deletions
diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py
index 42ec9673..4711f624 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/resources/templates/listing.html b/cli/onionshare_cli/resources/templates/listing.html
index 8458bb87..8e0dedf7 100644
--- a/cli/onionshare_cli/resources/templates/listing.html
+++ b/cli/onionshare_cli/resources/templates/listing.html
@@ -2,7 +2,7 @@
<html>
<head>
- <title>OnionShare</title>
+ <title>{% if title %}{{ title }}{% else %}OnionShare{% endif %}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="{{ static_url_path }}/img/favicon.ico" rel="icon" type="image/x-icon" />
@@ -14,7 +14,7 @@
<header class="d-flex">
<div class="logo-container">
<img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
- <h1>OnionShare</h1>
+ <h1>{% if title %}{{ title }}{% else %}OnionShare{% endif %}</h1>
</div>
</header>
@@ -57,4 +57,4 @@
</div>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/cli/onionshare_cli/resources/templates/receive.html b/cli/onionshare_cli/resources/templates/receive.html
index 20f4bb7e..08b9623c 100644
--- a/cli/onionshare_cli/resources/templates/receive.html
+++ b/cli/onionshare_cli/resources/templates/receive.html
@@ -1,46 +1,49 @@
<!DOCTYPE html>
<html>
- <head>
- <title>OnionShare</title>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <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>
- <body>
-
- <header class="clearfix">
- <img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
- <h1>OnionShare</h1>
- </header>
-
- <div class="upload-wrapper">
- <p><img class="logo" src="{{ static_url_path }}/img/logo_large.png" title="OnionShare"></p>
-
- <p class="upload-header">Send Files</p>
- <p class="upload-description">Select the files you want to send, then click "Send Files"...</p>
-
- <div id="uploads"></div>
-
- <div>
- <ul id="flashes" class="flashes">
- {% with messages = get_flashed_messages(with_categories=true) %}
- {% if messages %}
- {% for category, message in messages %}
- <li class="{{ category }}">{{ message }}</li>
- {% endfor %}
- {% endif %}
- {% endwith %}
- </ul>
- </div>
-
- <form id="send" method="post" enctype="multipart/form-data" action="/upload">
- <p><input type="file" id="file-select" name="file[]" multiple /></p>
- <p><button type="submit" id="send-button" class="button">Send Files</button></p>
- </form>
+<head>
+ <title>{% if title %}{{ title }}{% else %}OnionShare Dropbox{% endif %}</title>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <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>
+
+<body>
+
+ <header class="clearfix">
+ <img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
+ <h1>{% if title %}{{ title }}{% else %}OnionShare Dropbox{% endif %}</h1>
+ </header>
+
+ <div class="upload-wrapper">
+ <p><img class="logo" src="{{ static_url_path }}/img/logo_large.png" title="OnionShare"></p>
+
+ <p class="upload-header">Send Files</p>
+ <p class="upload-description">Select the files you want to send, then click "Send Files"...</p>
+
+ <div id="uploads"></div>
+
+ <div>
+ <ul id="flashes" class="flashes">
+ {% with messages = get_flashed_messages(with_categories=true) %}
+ {% if messages %}
+ {% for category, message in messages %}
+ <li class="{{ category }}">{{ message }}</li>
+ {% endfor %}
+ {% endif %}
+ {% endwith %}
+ </ul>
</div>
- <script src="{{ static_url_path }}/js/jquery-3.5.1.min.js"></script>
- <script async src="{{ static_url_path }}/js/receive.js" id="receive-script"></script>
- </body>
-</html>
+
+ <form id="send" method="post" enctype="multipart/form-data" action="/upload">
+ <p><input type="file" id="file-select" name="file[]" multiple /></p>
+ <p><button type="submit" id="send-button" class="button">Send Files</button></p>
+ </form>
+
+ </div>
+ <script src="{{ static_url_path }}/js/jquery-3.5.1.min.js"></script>
+ <script async src="{{ static_url_path }}/js/receive.js" id="receive-script"></script>
+</body>
+
+</html> \ No newline at end of file
diff --git a/cli/onionshare_cli/resources/templates/send.html b/cli/onionshare_cli/resources/templates/send.html
index dd30bfdd..bd9bd631 100644
--- a/cli/onionshare_cli/resources/templates/send.html
+++ b/cli/onionshare_cli/resources/templates/send.html
@@ -2,9 +2,9 @@
<html>
<head>
- <title>OnionShare</title>
+ <title>{% if title %}{{ title }}{% else %}OnionShare{% endif %}</title>
<meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<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">
<meta name="onionshare-filename" content="{{ filename }}">
@@ -16,7 +16,7 @@
<header class="d-flex">
<div class="logo-container">
<img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
- <h1>OnionShare</h1>
+ <h1>{% if title %}{{ title }}{% else %}OnionShare{% endif %}</h1>
</div>
<div class="information d-flex">
<div>Total size: <strong>{{ filesize_human }}</strong> {% if is_zipped %} (compressed){% endif %}</div>
@@ -25,10 +25,11 @@
</header>
{% if breadcrumbs %}
- <ul class="breadcrumbs">
- {% for breadcrumb in breadcrumbs %}<li><a href="{{ breadcrumb[1] }}">{{ breadcrumb[0] }}</a> <span class="sep">&#8227;</span></li>{% endfor %}<li>{{ breadcrumbs_leaf }}</li>
- </ul>
- {% endif %}
+ <ul class="breadcrumbs">
+ {% for breadcrumb in breadcrumbs %}<li><a href="{{ breadcrumb[1] }}">{{ breadcrumb[0] }}</a> <span
+ class="sep">&#8227;</span></li>{% endfor %}<li>{{ breadcrumbs_leaf }}</li>
+ </ul>
+ {% endif %}
<div class="file-list" id="file-list">
<div class="d-flex">
@@ -66,4 +67,4 @@
<script async src="{{ static_url_path }}/js/send.js" charset="utf-8"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/cli/onionshare_cli/resources/templates/thankyou.html b/cli/onionshare_cli/resources/templates/thankyou.html
index aa0bc553..8e92386d 100644
--- a/cli/onionshare_cli/resources/templates/thankyou.html
+++ b/cli/onionshare_cli/resources/templates/thankyou.html
@@ -4,7 +4,7 @@
<head>
<title>OnionShare is closed</title>
<meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<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>
@@ -12,7 +12,7 @@
<body>
<header class="clearfix">
<img class="logo" src="{{ static_url_path }}/img/logo.png" title="OnionShare">
- <h1>OnionShare</h1>
+ <h1>{% if title %}{{ title }}{% else %}OnionShare{% endif %}</h1>
</header>
<div class="info-wrapper">
@@ -24,4 +24,4 @@
</div>
</body>
-</html>
+</html> \ No newline at end of file
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)
diff --git a/cli/onionshare_cli/web/receive_mode.py b/cli/onionshare_cli/web/receive_mode.py
index 46f471a8..21e83f58 100644
--- a/cli/onionshare_cli/web/receive_mode.py
+++ b/cli/onionshare_cli/web/receive_mode.py
@@ -64,7 +64,9 @@ class ReceiveModeWeb:
self.web.add_request(self.web.REQUEST_LOAD, request.path)
r = make_response(
render_template(
- "receive.html", static_url_path=self.web.static_url_path
+ "receive.html",
+ static_url_path=self.web.static_url_path,
+ title=self.web.settings.get("general", "title"),
)
)
return self.web.add_security_headers(r)
@@ -168,6 +170,7 @@ class ReceiveModeWeb:
"new_body": render_template(
"thankyou.html",
static_url_path=self.web.static_url_path,
+ title=self.web.settings.get("general", "title"),
)
}
)
@@ -176,6 +179,7 @@ class ReceiveModeWeb:
r = make_response(
render_template("thankyou.html"),
static_url_path=self.web.static_url_path,
+ title=self.web.settings.get("general", "title"),
)
return self.web.add_security_headers(r)
diff --git a/cli/onionshare_cli/web/share_mode.py b/cli/onionshare_cli/web/share_mode.py
index ad5825a2..b0b096ca 100644
--- a/cli/onionshare_cli/web/share_mode.py
+++ b/cli/onionshare_cli/web/share_mode.py
@@ -390,6 +390,7 @@ class ShareModeWeb(SendBaseModeWeb):
is_zipped=self.is_zipped,
static_url_path=self.web.static_url_path,
download_individual_files=self.download_individual_files,
+ title=self.web.settings.get("general", "title"),
)
)
diff --git a/cli/onionshare_cli/web/website_mode.py b/cli/onionshare_cli/web/website_mode.py
index 5718c9a9..6badd399 100644
--- a/cli/onionshare_cli/web/website_mode.py
+++ b/cli/onionshare_cli/web/website_mode.py
@@ -60,6 +60,7 @@ class WebsiteModeWeb(SendBaseModeWeb):
breadcrumbs=breadcrumbs,
breadcrumbs_leaf=breadcrumbs_leaf,
static_url_path=self.web.static_url_path,
+ title=self.web.settings.get("general", "title"),
)
)