コミットを比較
2 コミット
作成者 | SHA1 | 日付 |
---|---|---|
n9k | 0c6792894a | |
n9k | a1862b9080 |
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from quart_compress import Compress
|
from quart_compress import Compress
|
||||||
|
@ -11,6 +12,7 @@ from anonstream.config import update_flask_from_toml
|
||||||
from anonstream.emote import load_emote_schema
|
from anonstream.emote import load_emote_schema
|
||||||
from anonstream.quart import Quart
|
from anonstream.quart import Quart
|
||||||
from anonstream.utils.captcha import create_captcha_factory, create_captcha_signer
|
from anonstream.utils.captcha import create_captcha_factory, create_captcha_signer
|
||||||
|
from anonstream.utils.locale import validate_locale, Nonconforming
|
||||||
from anonstream.utils.user import generate_blank_allowedness
|
from anonstream.utils.user import generate_blank_allowedness
|
||||||
|
|
||||||
__version__ = '1.6.6'
|
__version__ = '1.6.6'
|
||||||
|
@ -54,6 +56,22 @@ def create_app(toml_config):
|
||||||
except (OSError, json.JSONDecodeError) as e:
|
except (OSError, json.JSONDecodeError) as e:
|
||||||
raise AssertionError(f'couldn\'t load emote schema: {e!r}') from e
|
raise AssertionError(f'couldn\'t load emote schema: {e!r}') from e
|
||||||
|
|
||||||
|
# Read locales
|
||||||
|
app.locales = {}
|
||||||
|
for lang in app.config['LOCALE_OFFERED']:
|
||||||
|
filepath = os.path.join(app.config['LOCALE_DIRECTORY'], f'{lang}.json')
|
||||||
|
with open(filepath) as fp:
|
||||||
|
locale = json.load(fp)
|
||||||
|
try:
|
||||||
|
validate_locale(locale)
|
||||||
|
except Nonconforming as e:
|
||||||
|
error, *_ = e.args
|
||||||
|
assert False, f'error in locale {lang!r}: {error}'
|
||||||
|
else:
|
||||||
|
app.locales[lang] = locale
|
||||||
|
app.lang = app.config['LOCALE_DEFAULT']
|
||||||
|
app.locales[None] = app.locales[app.lang]
|
||||||
|
|
||||||
# State for tasks
|
# State for tasks
|
||||||
app.users_update_buffer = set()
|
app.users_update_buffer = set()
|
||||||
app.stream_title = None
|
app.stream_title = None
|
||||||
|
|
|
@ -50,34 +50,24 @@ def add_chat_message(user, nonce, comment, ignore_empty=False):
|
||||||
user['linespan'],
|
user['linespan'],
|
||||||
))
|
))
|
||||||
if total_recent_linespan > CONFIG['FLOOD_LINE_THRESHOLD']:
|
if total_recent_linespan > CONFIG['FLOOD_LINE_THRESHOLD']:
|
||||||
raise Rejected(
|
raise Rejected('message_ratelimited', CONFIG['FLOOD_LINE_THRESHOLD'])
|
||||||
f'Chat overuse in the last '
|
|
||||||
f'{CONFIG["FLOOD_LINE_DURATION"]:.0f} seconds'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check message
|
# Check message
|
||||||
message_id = generate_nonce_hash(nonce)
|
message_id = generate_nonce_hash(nonce)
|
||||||
if message_id in MESSAGES_BY_ID:
|
if message_id in MESSAGES_BY_ID:
|
||||||
raise Rejected('Discarded suspected duplicate message')
|
raise Rejected('message_suspected_duplicate')
|
||||||
if len(comment) == 0:
|
if len(comment) == 0:
|
||||||
raise Rejected('Message was empty')
|
raise Rejected('message_empty')
|
||||||
if len(comment.strip()) == 0:
|
if len(comment.strip()) == 0:
|
||||||
raise Rejected('Message was practically empty')
|
raise Rejected('message_practically_empty')
|
||||||
if len(comment) > CONFIG['CHAT_COMMENT_MAX_LENGTH']:
|
if len(comment) > CONFIG['CHAT_COMMENT_MAX_LENGTH']:
|
||||||
raise Rejected(
|
raise Rejected('message_too_long', CONFIG['CHAT_COMMENT_MAX_LENGTH'])
|
||||||
f'Message exceeded {CONFIG["CHAT_COMMENT_MAX_LENGTH"]} chars'
|
|
||||||
)
|
|
||||||
|
|
||||||
if comment.count('\n') + 1 > CONFIG['CHAT_COMMENT_MAX_LINES']:
|
if comment.count('\n') + 1 > CONFIG['CHAT_COMMENT_MAX_LINES']:
|
||||||
raise Rejected(
|
raise Rejected('message_too_many_lines', CONFIG['CHAT_COMMENT_MAX_LINES'])
|
||||||
f'Message exceeded {CONFIG["CHAT_COMMENT_MAX_LINES"]} lines'
|
|
||||||
)
|
|
||||||
linespan = get_approx_linespan(comment)
|
linespan = get_approx_linespan(comment)
|
||||||
if linespan > CONFIG['CHAT_COMMENT_MAX_LINES']:
|
if linespan > CONFIG['CHAT_COMMENT_MAX_LINES']:
|
||||||
raise Rejected(
|
raise Rejected('message_too_many_apparent_lines', CONFIG['CHAT_COMMENT_MAX_LINES'])
|
||||||
f'Message would span {CONFIG["CHAT_COMMENT_MAX_LINES"]} '
|
|
||||||
f'or more lines'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Record linespan
|
# Record linespan
|
||||||
linespan_tuple = (timestamp, linespan)
|
linespan_tuple = (timestamp, linespan)
|
||||||
|
|
|
@ -40,6 +40,7 @@ def toml_to_flask_sections(config):
|
||||||
toml_to_flask_section_captcha,
|
toml_to_flask_section_captcha,
|
||||||
toml_to_flask_section_nojs,
|
toml_to_flask_section_nojs,
|
||||||
toml_to_flask_section_emote,
|
toml_to_flask_section_emote,
|
||||||
|
toml_to_flask_section_locale,
|
||||||
)
|
)
|
||||||
for toml_to_flask_section in TOML_TO_FLASK_SECTIONS:
|
for toml_to_flask_section in TOML_TO_FLASK_SECTIONS:
|
||||||
yield toml_to_flask_section(config)
|
yield toml_to_flask_section(config)
|
||||||
|
@ -171,3 +172,12 @@ def toml_to_flask_section_emote(config):
|
||||||
return {
|
return {
|
||||||
'EMOTE_SCHEMA': cfg['schema'],
|
'EMOTE_SCHEMA': cfg['schema'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def toml_to_flask_section_locale(config):
|
||||||
|
cfg = config['locale']
|
||||||
|
assert cfg['default'] in cfg['offered']
|
||||||
|
return {
|
||||||
|
'LOCALE_DEFAULT': cfg['default'],
|
||||||
|
'LOCALE_OFFERED': cfg['offered'],
|
||||||
|
'LOCALE_DIRECTORY': cfg['directory'],
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
from quart import current_app
|
||||||
|
|
||||||
|
LOCALES = current_app.locales
|
||||||
|
|
||||||
|
def get_lang_and_locale_from(context, burrow=(), validate=True):
|
||||||
|
lang = context.args.get('lang')
|
||||||
|
locale = LOCALES.get(lang)
|
||||||
|
if locale is None:
|
||||||
|
if validate:
|
||||||
|
lang = None
|
||||||
|
locale = LOCALES[None]
|
||||||
|
for key in burrow:
|
||||||
|
locale = locale[key]
|
||||||
|
return lang, locale
|
||||||
|
|
||||||
|
def get_lang_from(context, validate=True):
|
||||||
|
lang, locale = get_lang_and_locale_from(context, validate=validate)
|
||||||
|
return lang
|
||||||
|
|
||||||
|
def get_locale_from(context, burrow=()):
|
||||||
|
lang, locale = get_lang_and_locale_from(context)
|
||||||
|
return locale
|
|
@ -9,6 +9,7 @@ from werkzeug.exceptions import Forbidden, NotFound, TooManyRequests
|
||||||
|
|
||||||
from anonstream.access import add_failure, pop_failure
|
from anonstream.access import add_failure, pop_failure
|
||||||
from anonstream.captcha import get_captcha_image, get_random_captcha_digest
|
from anonstream.captcha import get_captcha_image, get_random_captcha_digest
|
||||||
|
from anonstream.locale import get_lang_and_locale_from, get_lang_from, get_locale_from
|
||||||
from anonstream.segments import segments, StopSendingSegments
|
from anonstream.segments import segments, StopSendingSegments
|
||||||
from anonstream.stream import is_online, get_stream_uptime
|
from anonstream.stream import is_online, get_stream_uptime
|
||||||
from anonstream.user import watching, create_eyes, renew_eyes, EyesException, RatelimitedEyes, TooManyEyes, ensure_allowedness, Blacklisted, SecretClub
|
from anonstream.user import watching, create_eyes, renew_eyes, EyesException, RatelimitedEyes, TooManyEyes, ensure_allowedness, Blacklisted, SecretClub
|
||||||
|
@ -20,33 +21,41 @@ from anonstream.wrappers import with_timestamp
|
||||||
|
|
||||||
CAPTCHA_SIGNER = current_app.captcha_signer
|
CAPTCHA_SIGNER = current_app.captcha_signer
|
||||||
STATIC_DIRECTORY = current_app.root_path / 'static'
|
STATIC_DIRECTORY = current_app.root_path / 'static'
|
||||||
|
LANG = current_app.lang
|
||||||
|
|
||||||
@current_app.route('/')
|
@current_app.route('/')
|
||||||
@with_user_from(request, fallback_to_token=True, ignore_allowedness=True)
|
@with_user_from(request, fallback_to_token=True, ignore_allowedness=True)
|
||||||
async def home(timestamp, user_or_token):
|
async def home(timestamp, user_or_token):
|
||||||
|
lang, locale = get_lang_and_locale_from(request, burrow=('anonstream',))
|
||||||
match user_or_token:
|
match user_or_token:
|
||||||
case str() | None as token:
|
case str() | None as token:
|
||||||
failure_id = request.args.get('failure', type=int)
|
failure_id = request.args.get('failure', type=int)
|
||||||
|
failure = pop_failure(failure_id)
|
||||||
response = await render_template(
|
response = await render_template(
|
||||||
'captcha.html',
|
'captcha.html',
|
||||||
csp=generate_csp(),
|
csp=generate_csp(),
|
||||||
token=token,
|
token=token,
|
||||||
|
request_lang=get_lang_from(request, validate=False),
|
||||||
|
locale=locale['captcha'],
|
||||||
digest=get_random_captcha_digest(),
|
digest=get_random_captcha_digest(),
|
||||||
failure=pop_failure(failure_id),
|
failure=locale['internal'].get(failure),
|
||||||
)
|
)
|
||||||
case dict() as user:
|
case dict() as user:
|
||||||
try:
|
try:
|
||||||
ensure_allowedness(user, timestamp=timestamp)
|
ensure_allowedness(user, timestamp=timestamp)
|
||||||
except Blacklisted:
|
except Blacklisted:
|
||||||
raise Forbidden('You have been blacklisted.')
|
raise Forbidden(locale['error']['blacklisted'])
|
||||||
except SecretClub:
|
except SecretClub:
|
||||||
# TODO allow changing tripcode
|
# TODO allow changing tripcode
|
||||||
raise Forbidden('You have not been whitelisted.')
|
raise Forbidden(locale['error']['not_whitelisted'])
|
||||||
else:
|
else:
|
||||||
response = await render_template(
|
response = await render_template(
|
||||||
'home.html',
|
'home.html',
|
||||||
csp=generate_csp(),
|
csp=generate_csp(),
|
||||||
user=user,
|
user=user,
|
||||||
|
lang=lang,
|
||||||
|
default_lang=LANG,
|
||||||
|
locale=locale['home'],
|
||||||
version=current_app.version,
|
version=current_app.version,
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
@ -54,27 +63,22 @@ async def home(timestamp, user_or_token):
|
||||||
@current_app.route('/stream.mp4')
|
@current_app.route('/stream.mp4')
|
||||||
@with_user_from(request)
|
@with_user_from(request)
|
||||||
async def stream(timestamp, user):
|
async def stream(timestamp, user):
|
||||||
|
locale = get_locale_from(request)['anonstream']['error']
|
||||||
if not is_online():
|
if not is_online():
|
||||||
raise NotFound('The stream is offline.')
|
raise NotFound(locale['offline'])
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
eyes_id = create_eyes(user, tuple(request.headers))
|
eyes_id = create_eyes(user, tuple(request.headers))
|
||||||
except RatelimitedEyes as e:
|
except RatelimitedEyes as e:
|
||||||
retry_after, *_ = e.args
|
retry_after, *_ = e.args
|
||||||
error = TooManyRequests(
|
error = TooManyRequests(locale['ratelimit'] % retry_after)
|
||||||
f'You have requested the stream recently. '
|
|
||||||
f'Try again in {retry_after:.1f} seconds.'
|
|
||||||
)
|
|
||||||
response = await current_app.handle_http_exception(error)
|
response = await current_app.handle_http_exception(error)
|
||||||
response = await make_response(response)
|
response = await make_response(response)
|
||||||
response.headers['Retry-After'] = math.ceil(retry_after)
|
response.headers['Retry-After'] = math.ceil(retry_after)
|
||||||
raise abort(response)
|
raise abort(response)
|
||||||
except TooManyEyes as e:
|
except TooManyEyes as e:
|
||||||
n_eyes, *_ = e.args
|
n_eyes, *_ = e.args
|
||||||
raise TooManyRequests(
|
raise TooManyRequests(locale['limit'] % n_eyes)
|
||||||
f'You have made {n_eyes} concurrent requests for the stream. '
|
|
||||||
f'End one of those before making a new request.'
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
@with_timestamp(precise=True)
|
@with_timestamp(precise=True)
|
||||||
def segment_read_hook(timestamp, uri):
|
def segment_read_hook(timestamp, uri):
|
||||||
|
@ -97,7 +101,7 @@ async def stream(timestamp, user):
|
||||||
@current_app.route('/login')
|
@current_app.route('/login')
|
||||||
@auth_required
|
@auth_required
|
||||||
async def login():
|
async def login():
|
||||||
return redirect(url_for('home'), 303)
|
return redirect(url_for('home', lang=get_lang_from(request)), 303)
|
||||||
|
|
||||||
@current_app.route('/captcha.jpg')
|
@current_app.route('/captcha.jpg')
|
||||||
@with_user_from(request, fallback_to_token=True)
|
@with_user_from(request, fallback_to_token=True)
|
||||||
|
@ -119,20 +123,19 @@ async def access(timestamp, user_or_token):
|
||||||
answer = form.get('answer', '')
|
answer = form.get('answer', '')
|
||||||
match check_captcha_digest(CAPTCHA_SIGNER, digest, answer):
|
match check_captcha_digest(CAPTCHA_SIGNER, digest, answer):
|
||||||
case Answer.MISSING:
|
case Answer.MISSING:
|
||||||
failure_id = add_failure('Captcha is required')
|
failure_id = add_failure('captcha_required')
|
||||||
case Answer.BAD:
|
case Answer.BAD:
|
||||||
failure_id = add_failure('Captcha was incorrect')
|
failure_id = add_failure('captcha_incorrect')
|
||||||
case Answer.EXPIRED:
|
case Answer.EXPIRED:
|
||||||
failure_id = add_failure('Captcha has expired')
|
failure_id = add_failure('captcha_expired')
|
||||||
case Answer.OK:
|
case Answer.OK:
|
||||||
failure_id = None
|
failure_id = None
|
||||||
user = generate_and_add_user(timestamp, token, verified=True)
|
user = generate_and_add_user(timestamp, token, verified=True)
|
||||||
if failure_id is not None:
|
|
||||||
url = url_for('home', token=token, failure=failure_id)
|
|
||||||
raise abort(redirect(url, 303))
|
|
||||||
case dict() as user:
|
case dict() as user:
|
||||||
pass
|
token = user['token']
|
||||||
url = url_for('home', token=user['token'])
|
failure_id = None
|
||||||
|
lang = get_lang_from(request, validate=failure_id is None)
|
||||||
|
url = url_for('home', token=token, lang=lang, failure=failure_id)
|
||||||
return redirect(url, 303)
|
return redirect(url, 303)
|
||||||
|
|
||||||
@current_app.route('/static/<path:filename>')
|
@current_app.route('/static/<path:filename>')
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
from quart import current_app, render_template
|
from quart import current_app, render_template, request
|
||||||
|
|
||||||
from werkzeug.exceptions import default_exceptions
|
from werkzeug.exceptions import default_exceptions
|
||||||
|
|
||||||
|
from anonstream.locale import get_locale_from
|
||||||
|
|
||||||
for error in default_exceptions:
|
for error in default_exceptions:
|
||||||
async def handle(error):
|
async def handle(error):
|
||||||
return await render_template('error.html', error=error), error.code
|
if error.description == error.__class__.description:
|
||||||
|
error.description = None
|
||||||
|
return (
|
||||||
|
await render_template(
|
||||||
|
'error.html', error=error,
|
||||||
|
locale=get_locale_from(request)['http'],
|
||||||
|
), error.code
|
||||||
|
)
|
||||||
current_app.register_error_handler(error, handle)
|
current_app.register_error_handler(error, handle)
|
||||||
|
|
|
@ -5,6 +5,7 @@ from quart import current_app, request, render_template, redirect, url_for, esca
|
||||||
|
|
||||||
from anonstream.captcha import get_random_captcha_digest_for
|
from anonstream.captcha import get_random_captcha_digest_for
|
||||||
from anonstream.chat import add_chat_message, Rejected
|
from anonstream.chat import add_chat_message, Rejected
|
||||||
|
from anonstream.locale import get_lang_and_locale_from, get_lang_from, get_locale_from
|
||||||
from anonstream.stream import is_online, get_stream_title, get_stream_uptime_and_viewership
|
from anonstream.stream import is_online, get_stream_title, get_stream_uptime_and_viewership
|
||||||
from anonstream.user import add_state, pop_state, try_change_appearance, update_presence, get_users_by_presence, Presence, verify, deverify, BadCaptcha, reading
|
from anonstream.user import add_state, pop_state, try_change_appearance, update_presence, get_users_by_presence, Presence, verify, deverify, BadCaptcha, reading
|
||||||
from anonstream.routes.wrappers import with_user_from, render_template_with_etag
|
from anonstream.routes.wrappers import with_user_from, render_template_with_etag
|
||||||
|
@ -12,7 +13,6 @@ from anonstream.helpers.chat import get_scrollback
|
||||||
from anonstream.helpers.user import get_default_name
|
from anonstream.helpers.user import get_default_name
|
||||||
from anonstream.utils.chat import generate_nonce
|
from anonstream.utils.chat import generate_nonce
|
||||||
from anonstream.utils.security import generate_csp
|
from anonstream.utils.security import generate_csp
|
||||||
from anonstream.utils.user import concatenate_for_notice
|
|
||||||
|
|
||||||
CONFIG = current_app.config
|
CONFIG = current_app.config
|
||||||
USERS_BY_TOKEN = current_app.users_by_token
|
USERS_BY_TOKEN = current_app.users_by_token
|
||||||
|
@ -25,6 +25,7 @@ async def nojs_stream(timestamp, user):
|
||||||
csp=generate_csp(),
|
csp=generate_csp(),
|
||||||
user=user,
|
user=user,
|
||||||
online=is_online(),
|
online=is_online(),
|
||||||
|
locale=get_locale_from(request)['anonstream']['stream'],
|
||||||
)
|
)
|
||||||
|
|
||||||
@current_app.route('/info.html')
|
@current_app.route('/info.html')
|
||||||
|
@ -37,6 +38,7 @@ async def nojs_info(timestamp, user):
|
||||||
{'csp': generate_csp()},
|
{'csp': generate_csp()},
|
||||||
refresh=CONFIG['NOJS_REFRESH_INFO'],
|
refresh=CONFIG['NOJS_REFRESH_INFO'],
|
||||||
user=user,
|
user=user,
|
||||||
|
locale=get_locale_from(request)['anonstream']['info'],
|
||||||
viewership=viewership,
|
viewership=viewership,
|
||||||
uptime=uptime,
|
uptime=uptime,
|
||||||
title=await get_stream_title(),
|
title=await get_stream_title(),
|
||||||
|
@ -53,6 +55,7 @@ async def nojs_chat_messages(timestamp, user):
|
||||||
refresh=CONFIG['NOJS_REFRESH_MESSAGES'],
|
refresh=CONFIG['NOJS_REFRESH_MESSAGES'],
|
||||||
user=user,
|
user=user,
|
||||||
users_by_token=USERS_BY_TOKEN,
|
users_by_token=USERS_BY_TOKEN,
|
||||||
|
locale=get_locale_from(request)['anonstream']['chat'],
|
||||||
messages=get_scrollback(current_app.messages),
|
messages=get_scrollback(current_app.messages),
|
||||||
timeout=CONFIG['NOJS_TIMEOUT_CHAT'],
|
timeout=CONFIG['NOJS_TIMEOUT_CHAT'],
|
||||||
get_default_name=get_default_name,
|
get_default_name=get_default_name,
|
||||||
|
@ -61,7 +64,12 @@ async def nojs_chat_messages(timestamp, user):
|
||||||
@current_app.route('/chat/messages')
|
@current_app.route('/chat/messages')
|
||||||
@with_user_from(request)
|
@with_user_from(request)
|
||||||
async def nojs_chat_messages_redirect(timestamp, user):
|
async def nojs_chat_messages_redirect(timestamp, user):
|
||||||
url = url_for('nojs_chat_messages', token=user['token'], _anchor='end')
|
url = url_for(
|
||||||
|
'nojs_chat_messages',
|
||||||
|
token=user['token'],
|
||||||
|
lang=get_lang_from(request),
|
||||||
|
_anchor='end',
|
||||||
|
)
|
||||||
return redirect(url, 303)
|
return redirect(url, 303)
|
||||||
|
|
||||||
@current_app.route('/chat/users.html')
|
@current_app.route('/chat/users.html')
|
||||||
|
@ -73,6 +81,7 @@ async def nojs_chat_users(timestamp, user):
|
||||||
{'csp': generate_csp()},
|
{'csp': generate_csp()},
|
||||||
refresh=CONFIG['NOJS_REFRESH_USERS'],
|
refresh=CONFIG['NOJS_REFRESH_USERS'],
|
||||||
user=user,
|
user=user,
|
||||||
|
locale=get_locale_from(request)['anonstream']['chat'],
|
||||||
get_default_name=get_default_name,
|
get_default_name=get_default_name,
|
||||||
users_watching=users_by_presence[Presence.WATCHING],
|
users_watching=users_by_presence[Presence.WATCHING],
|
||||||
users_notwatching=users_by_presence[Presence.NOTWATCHING],
|
users_notwatching=users_by_presence[Presence.NOTWATCHING],
|
||||||
|
@ -82,6 +91,7 @@ async def nojs_chat_users(timestamp, user):
|
||||||
@current_app.route('/chat/form.html')
|
@current_app.route('/chat/form.html')
|
||||||
@with_user_from(request)
|
@with_user_from(request)
|
||||||
async def nojs_chat_form(timestamp, user):
|
async def nojs_chat_form(timestamp, user):
|
||||||
|
lang, locale = get_lang_and_locale_from(request)
|
||||||
state_id = request.args.get('state', type=int)
|
state_id = request.args.get('state', type=int)
|
||||||
state = pop_state(user, state_id)
|
state = pop_state(user, state_id)
|
||||||
prefer_chat_form = request.args.get('landing') != 'appearance'
|
prefer_chat_form = request.args.get('landing') != 'appearance'
|
||||||
|
@ -89,8 +99,10 @@ async def nojs_chat_form(timestamp, user):
|
||||||
'nojs_chat_form.html',
|
'nojs_chat_form.html',
|
||||||
csp=generate_csp(),
|
csp=generate_csp(),
|
||||||
user=user,
|
user=user,
|
||||||
state=state,
|
|
||||||
prefer_chat_form=prefer_chat_form,
|
prefer_chat_form=prefer_chat_form,
|
||||||
|
state=state,
|
||||||
|
lang=lang,
|
||||||
|
locale=locale['anonstream'],
|
||||||
nonce=generate_nonce(),
|
nonce=generate_nonce(),
|
||||||
digest=get_random_captcha_digest_for(user),
|
digest=get_random_captcha_digest_for(user),
|
||||||
default_name=get_default_name(user),
|
default_name=get_default_name(user),
|
||||||
|
@ -110,7 +122,12 @@ async def nojs_chat_form_redirect(timestamp, user):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
state_id = None
|
state_id = None
|
||||||
url = url_for('nojs_chat_form', token=user['token'], state=state_id)
|
url = url_for(
|
||||||
|
'nojs_chat_form',
|
||||||
|
token=user['token'],
|
||||||
|
lang=get_lang_from(request),
|
||||||
|
state=state_id,
|
||||||
|
)
|
||||||
return redirect(url, 303)
|
return redirect(url, 303)
|
||||||
|
|
||||||
@current_app.post('/chat/message')
|
@current_app.post('/chat/message')
|
||||||
|
@ -124,10 +141,10 @@ async def nojs_submit_message(timestamp, user):
|
||||||
try:
|
try:
|
||||||
verification_happened = verify(user, digest, answer)
|
verification_happened = verify(user, digest, answer)
|
||||||
except BadCaptcha as e:
|
except BadCaptcha as e:
|
||||||
notice, *_ = e.args
|
string, *args = e.args
|
||||||
state_id = add_state(
|
state_id = add_state(
|
||||||
user,
|
user,
|
||||||
notice=notice,
|
notice=[(string, args)],
|
||||||
comment=comment[:CONFIG['CHAT_COMMENT_MAX_LENGTH']],
|
comment=comment[:CONFIG['CHAT_COMMENT_MAX_LENGTH']],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -143,10 +160,10 @@ async def nojs_submit_message(timestamp, user):
|
||||||
)
|
)
|
||||||
message_was_added = seq is not None
|
message_was_added = seq is not None
|
||||||
except Rejected as e:
|
except Rejected as e:
|
||||||
notice, *_ = e.args
|
string, *args = e.args
|
||||||
state_id = add_state(
|
state_id = add_state(
|
||||||
user,
|
user,
|
||||||
notice=notice,
|
notice=[(string, args)],
|
||||||
comment=comment[:CONFIG['CHAT_COMMENT_MAX_LENGTH']],
|
comment=comment[:CONFIG['CHAT_COMMENT_MAX_LENGTH']],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -157,6 +174,7 @@ async def nojs_submit_message(timestamp, user):
|
||||||
url = url_for(
|
url = url_for(
|
||||||
'nojs_chat_form',
|
'nojs_chat_form',
|
||||||
token=user['token'],
|
token=user['token'],
|
||||||
|
lang=get_lang_from(request),
|
||||||
landing='chat',
|
landing='chat',
|
||||||
state=state_id,
|
state=state_id,
|
||||||
)
|
)
|
||||||
|
@ -185,16 +203,17 @@ async def nojs_submit_appearance(timestamp, user):
|
||||||
# Change appearance (iff form data was good)
|
# Change appearance (iff form data was good)
|
||||||
errors = try_change_appearance(user, name, color, password, want_tripcode)
|
errors = try_change_appearance(user, name, color, password, want_tripcode)
|
||||||
if errors:
|
if errors:
|
||||||
notice = Markup('<br>').join(
|
notice = []
|
||||||
concatenate_for_notice(*error.args) for error in errors
|
for string, *args in (error.args for error in errors):
|
||||||
)
|
notice.append((string, args))
|
||||||
else:
|
else:
|
||||||
notice = 'Changed appearance'
|
notice = [('appearance_changed', ())]
|
||||||
|
|
||||||
state_id = add_state(user, notice=notice, verbose=len(errors) > 1)
|
state_id = add_state(user, notice=notice)
|
||||||
url = url_for(
|
url = url_for(
|
||||||
'nojs_chat_form',
|
'nojs_chat_form',
|
||||||
token=user['token'],
|
token=user['token'],
|
||||||
|
lang=get_lang_from(request),
|
||||||
landing='appearance' if errors else 'chat',
|
landing='appearance' if errors else 'chat',
|
||||||
state=state_id,
|
state=state_id,
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,11 +8,12 @@ import string
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from urllib.parse import quote, unquote
|
from urllib.parse import quote, unquote
|
||||||
|
|
||||||
from quart import current_app, request, make_response, render_template, request, url_for, Markup
|
from quart import current_app, request, make_response, render_template, request, url_for, escape, Markup
|
||||||
from werkzeug.exceptions import BadRequest, Unauthorized, Forbidden
|
from werkzeug.exceptions import BadRequest, Unauthorized, Forbidden
|
||||||
from werkzeug.security import check_password_hash
|
from werkzeug.security import check_password_hash
|
||||||
|
|
||||||
from anonstream.broadcast import broadcast
|
from anonstream.broadcast import broadcast
|
||||||
|
from anonstream.locale import get_lang_and_locale_from, get_locale_from
|
||||||
from anonstream.user import ensure_allowedness, Blacklisted, SecretClub
|
from anonstream.user import ensure_allowedness, Blacklisted, SecretClub
|
||||||
from anonstream.helpers.user import generate_user
|
from anonstream.helpers.user import generate_user
|
||||||
from anonstream.utils.user import generate_token, Presence
|
from anonstream.utils.user import generate_token, Presence
|
||||||
|
@ -53,18 +54,11 @@ def auth_required(f):
|
||||||
async def wrapper(*args, **kwargs):
|
async def wrapper(*args, **kwargs):
|
||||||
if check_auth(request):
|
if check_auth(request):
|
||||||
return await f(*args, **kwargs)
|
return await f(*args, **kwargs)
|
||||||
hint = (
|
locale = get_locale_from(request)['anonstream']['error']
|
||||||
'The broadcaster should log in with the credentials printed in '
|
|
||||||
'their terminal.'
|
|
||||||
)
|
|
||||||
if request.authorization is None:
|
if request.authorization is None:
|
||||||
description = hint
|
description = locale['broadcaster_should_log_in']
|
||||||
else:
|
else:
|
||||||
description = Markup(
|
description = locale['wrong_username_or_password']
|
||||||
f'Wrong username or password. Refresh the page to try again. '
|
|
||||||
f'<br>'
|
|
||||||
f'{hint}'
|
|
||||||
)
|
|
||||||
error = Unauthorized(description)
|
error = Unauthorized(description)
|
||||||
response = await current_app.handle_http_exception(error)
|
response = await current_app.handle_http_exception(error)
|
||||||
response = await make_response(response)
|
response = await make_response(response)
|
||||||
|
@ -107,11 +101,11 @@ def with_user_from(context, fallback_to_token=False, ignore_allowedness=False):
|
||||||
|
|
||||||
# Reject invalid tokens
|
# Reject invalid tokens
|
||||||
if isinstance(token, str) and not RE_TOKEN.fullmatch(token):
|
if isinstance(token, str) and not RE_TOKEN.fullmatch(token):
|
||||||
raise BadRequest(Markup(
|
locale = get_locale_from(context)
|
||||||
f'Your token contains disallowed characters or is too '
|
args = (
|
||||||
f'long. Tokens must match this regular expression: <br>'
|
Markup(f'<br><code>{RE_TOKEN.pattern}</code>'),
|
||||||
f'<code>{RE_TOKEN.pattern}</code>'
|
)
|
||||||
))
|
raise BadRequest(escape(locale['invalid_token']) % args)
|
||||||
|
|
||||||
# Only logged in broadcaster may have the broadcaster's token
|
# Only logged in broadcaster may have the broadcaster's token
|
||||||
if (
|
if (
|
||||||
|
@ -119,15 +113,16 @@ def with_user_from(context, fallback_to_token=False, ignore_allowedness=False):
|
||||||
and isinstance(token, str)
|
and isinstance(token, str)
|
||||||
and hmac.compare_digest(token, CONFIG['AUTH_TOKEN'])
|
and hmac.compare_digest(token, CONFIG['AUTH_TOKEN'])
|
||||||
):
|
):
|
||||||
raise Unauthorized(Markup(
|
lang, locale = get_lang_and_locale_from(
|
||||||
f"You are using the broadcaster's token but you are "
|
context, burrow=('anonstream', 'error'),
|
||||||
f"not logged in. The broadcaster should "
|
)
|
||||||
f"<a href=\"{url_for('login')}\" target=\"_top\">"
|
args = (
|
||||||
f"click here"
|
Markup(f'''<a href="{url_for('login', lang=lang)}" target="_top">'''),
|
||||||
f"</a> "
|
Markup(f'''</a>'''),
|
||||||
f"and log in with the credentials printed in their "
|
)
|
||||||
f"terminal when they started anonstream."
|
raise Unauthorized(
|
||||||
))
|
escape(locale['impostor']) % args
|
||||||
|
)
|
||||||
|
|
||||||
# Create response
|
# Create response
|
||||||
user = USERS_BY_TOKEN.get(token)
|
user = USERS_BY_TOKEN.get(token)
|
||||||
|
@ -136,19 +131,25 @@ def with_user_from(context, fallback_to_token=False, ignore_allowedness=False):
|
||||||
user['last']['seen'] = timestamp
|
user['last']['seen'] = timestamp
|
||||||
user['headers'] = tuple(context.headers)
|
user['headers'] = tuple(context.headers)
|
||||||
if not ignore_allowedness:
|
if not ignore_allowedness:
|
||||||
assert_allowedness(timestamp, user)
|
assert_allowedness(context, timestamp, user)
|
||||||
if user is not None and user['verified'] is not None:
|
if user is not None and user['verified'] is not None:
|
||||||
response = await f(timestamp, user, *args, **kwargs)
|
response = await f(timestamp, user, *args, **kwargs)
|
||||||
elif fallback_to_token:
|
elif fallback_to_token:
|
||||||
#assert not broadcaster
|
#assert not broadcaster
|
||||||
response = await f(timestamp, token, *args, **kwargs)
|
response = await f(timestamp, token, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
raise Forbidden(Markup(
|
lang, locale = get_lang_and_locale_from(
|
||||||
f"You have not solved the access captcha. "
|
context, burrow=('anonstream', 'error'),
|
||||||
f"<a href=\"{url_for('home', token=token)}\" target=\"_top\">"
|
)
|
||||||
f"Click here."
|
args = (
|
||||||
f"</a>"
|
Markup(f'''<a href="{url_for('home', token=token, lang=lang)}" target="_top">'''),
|
||||||
))
|
Markup(f'''</a>'''),
|
||||||
|
)
|
||||||
|
if user is None:
|
||||||
|
string = locale['captcha']
|
||||||
|
else:
|
||||||
|
string = locale['captcha_again']
|
||||||
|
raise Forbidden(escape(string) % args)
|
||||||
else:
|
else:
|
||||||
if user is not None:
|
if user is not None:
|
||||||
user['last']['seen'] = timestamp
|
user['last']['seen'] = timestamp
|
||||||
|
@ -161,7 +162,7 @@ def with_user_from(context, fallback_to_token=False, ignore_allowedness=False):
|
||||||
headers=tuple(context.headers),
|
headers=tuple(context.headers),
|
||||||
)
|
)
|
||||||
if not ignore_allowedness:
|
if not ignore_allowedness:
|
||||||
assert_allowedness(timestamp, user)
|
assert_allowedness(context, timestamp, user)
|
||||||
response = await f(timestamp, user, *args, **kwargs)
|
response = await f(timestamp, user, *args, **kwargs)
|
||||||
|
|
||||||
# Set cookie
|
# Set cookie
|
||||||
|
@ -229,10 +230,12 @@ def etag_conditional(f):
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def assert_allowedness(timestamp, user):
|
def assert_allowedness(context, timestamp, user):
|
||||||
try:
|
try:
|
||||||
ensure_allowedness(user, timestamp=timestamp)
|
ensure_allowedness(user, timestamp=timestamp)
|
||||||
except Blacklisted as e:
|
except Blacklisted as e:
|
||||||
raise Forbidden('You have been blacklisted.')
|
locale = get_locale_from(context)['anonstream']['error']
|
||||||
|
raise Forbidden(locale['blacklisted'])
|
||||||
except SecretClub as e:
|
except SecretClub as e:
|
||||||
raise Forbidden('You have not been whitelisted.')
|
locale = get_locale_from(context)['anonstream']['error']
|
||||||
|
raise Forbidden(locale['whitelisted'])
|
||||||
|
|
|
@ -7,21 +7,24 @@
|
||||||
const TOKEN = document.body.dataset.token;
|
const TOKEN = document.body.dataset.token;
|
||||||
const TOKEN_HASH = document.body.dataset.tokenHash;
|
const TOKEN_HASH = document.body.dataset.tokenHash;
|
||||||
|
|
||||||
|
/* language */
|
||||||
|
const LANG = document.firstElementChild.lang;
|
||||||
|
|
||||||
/* Content Security Policy nonce */
|
/* Content Security Policy nonce */
|
||||||
const CSP = document.body.dataset.csp;
|
const CSP = document.body.dataset.csp;
|
||||||
|
|
||||||
/* insert js-only markup */
|
/* insert js-only markup */
|
||||||
const jsmarkup_stream_video = '<video id="stream__video" autoplay controls></video>'
|
const jsmarkup_stream_video = '<video id="stream__video" autoplay controls></video>'
|
||||||
const jsmarkup_stream_offline = '<header id="stream__offline"><h1>[offline]</h1></header>'
|
const jsmarkup_stream_offline = '<header id="stream__offline"><h1 data-string="offline">[offline]</h1></header>'
|
||||||
const jsmarkup_info = '<div id="info_js" data-js="true"></div>';
|
const jsmarkup_info = '<div id="info_js" data-js="true"></div>';
|
||||||
const jsmarkup_info_float = '<aside id="info_js__float"></aside>';
|
const jsmarkup_info_float = '<aside id="info_js__float"></aside>';
|
||||||
const jsmarkup_info_float_button = '<button id="info_js__float__button" accesskey="r">Reload stream</button>';
|
const jsmarkup_info_float_button = '<button id="info_js__float__button" accesskey="r" data-string="reload_stream">Reload stream</button>';
|
||||||
const jsmarkup_info_float_viewership = '<div id="info_js__float__viewership"></div>';
|
const jsmarkup_info_float_viewership = '<div id="info_js__float__viewership"></div>';
|
||||||
const jsmarkup_info_float_uptime = '<div id="info_js__float__uptime"></div>';
|
const jsmarkup_info_float_uptime = '<div id="info_js__float__uptime"></div>';
|
||||||
const jsmarkup_info_title = '<header id="info_js__title"></header>';
|
const jsmarkup_info_title = '<header id="info_js__title"></header>';
|
||||||
const jsmarkup_chat_messages = `\
|
const jsmarkup_chat_messages = `\
|
||||||
<ol id="chat-messages_js" data-js="true"></ol>
|
<ol id="chat-messages_js" data-js="true"></ol>
|
||||||
<button id="chat-messages-unlock">Chat scroll paused. Click to resume.</button>`;
|
<button id="chat-messages-unlock" data-string="chat_scroll_paused">Chat scroll paused. Click to resume.</button>`;
|
||||||
const jsmarkup_chat_users = `\
|
const jsmarkup_chat_users = `\
|
||||||
<article id="chat-users_js">
|
<article id="chat-users_js">
|
||||||
<h5 id="chat-users_js__watching-header"></h5>
|
<h5 id="chat-users_js__watching-header"></h5>
|
||||||
|
@ -37,31 +40,31 @@ const jsmarkup_chat_form = `\
|
||||||
<div id="chat-live">
|
<div id="chat-live">
|
||||||
<span id="chat-live__ball"></span>
|
<span id="chat-live__ball"></span>
|
||||||
<span id="chat-live__status">
|
<span id="chat-live__status">
|
||||||
<span data-verbose="true">Not connected to chat</span>
|
<span data-verbose="true" data-string="not_connected_to_chat">Not connected to chat</span>
|
||||||
<span data-verbose="false">×</span>
|
<span data-verbose="false">×</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<input id="chat-form_js__submit" type="submit" value="Chat" accesskey="p" disabled>
|
<input id="chat-form_js__submit" type="submit" value="Chat" accesskey="p" disabled data-string="chat" data-string-attr="value">
|
||||||
<input id="chat-form_js__captcha-digest" type="hidden" name="captcha-digest" disabled>
|
<input id="chat-form_js__captcha-digest" type="hidden" name="captcha-digest" disabled>
|
||||||
<input id="chat-form_js__captcha-image" type="image" width="72" height="30">
|
<input id="chat-form_js__captcha-image" type="image" width="72" height="30">
|
||||||
<input id="chat-form_js__captcha-answer" name="captcha-answer" placeholder="Captcha" disabled>
|
<input id="chat-form_js__captcha-answer" name="captcha-answer" placeholder="Captcha" disabled data-string="captcha" data-string-attr="placeholder">
|
||||||
<input id="chat-form_js__settings" type="image" src="/static/settings.svg" width="28" height="28" alt="Settings">
|
<input id="chat-form_js__settings" type="image" src="/static/settings.svg" width="28" height="28" alt="Settings" data-string="settings" data-string-attr="alt">
|
||||||
<article id="chat-form_js__notice">
|
<article id="chat-form_js__notice">
|
||||||
<button id="chat-form_js__notice__button" type="button">
|
<button id="chat-form_js__notice__button" type="button">
|
||||||
<header id="chat-form_js__notice__button__header"></header>
|
<header id="chat-form_js__notice__button__header"></header>
|
||||||
<small>Click to dismiss</small>
|
<small data-string="click_to_dismiss">Click to dismiss</small>
|
||||||
</button>
|
</button>
|
||||||
</article>
|
</article>
|
||||||
</form>
|
</form>
|
||||||
<form id="appearance-form_js" data-hidden="">
|
<form id="appearance-form_js" data-hidden="">
|
||||||
<span id="appearance-form_js__label-name">Name:</span>
|
<span id="appearance-form_js__label-name" data-string="name">Name:</span>
|
||||||
<input id="appearance-form_js__name" name="name">
|
<input id="appearance-form_js__name" name="name">
|
||||||
<input id="appearance-form_js__color" type="color" name="color">
|
<input id="appearance-form_js__color" type="color" name="color">
|
||||||
<span id="appearance-form_js__label-tripcode">Tripcode:</span>
|
<span id="appearance-form_js__label-tripcode" data-string="tripcode">Tripcode:</span>
|
||||||
<input id="appearance-form_js__password" type="password" name="password" placeholder="(tripcode password)">
|
<input id="appearance-form_js__password" type="password" name="password" placeholder="(tripcode password)" data-string="tripcode_password" data-string-attr="placeholder">
|
||||||
<div id="appearance-form_js__row">
|
<div id="appearance-form_js__row">
|
||||||
<article id="appearance-form_js__row__result"></article>
|
<article id="appearance-form_js__row__result"></article>
|
||||||
<input id="appearance-form_js__row__submit" type="submit" value="Update">
|
<input id="appearance-form_js__row__submit" type="submit" value="Update" data-string="update" data-string-attr="value">
|
||||||
</div>
|
</div>
|
||||||
</form>`;
|
</form>`;
|
||||||
|
|
||||||
|
@ -247,7 +250,7 @@ const create_chat_user_components = (user) => {
|
||||||
} else {
|
} else {
|
||||||
const chat_user_insignia = document.createElement("b");
|
const chat_user_insignia = document.createElement("b");
|
||||||
chat_user_insignia.classList.add("chat-insignia")
|
chat_user_insignia.classList.add("chat-insignia")
|
||||||
chat_user_insignia.title = "Broadcaster";
|
chat_user_insignia.title = locale.broadcaster || "Broadcaster";
|
||||||
chat_user_insignia.innerText = "##";
|
chat_user_insignia.innerText = "##";
|
||||||
const chat_user_insignia_nbsp = document.createElement("span");
|
const chat_user_insignia_nbsp = document.createElement("span");
|
||||||
chat_user_insignia_nbsp.innerHTML = " "
|
chat_user_insignia_nbsp.innerHTML = " "
|
||||||
|
@ -275,6 +278,7 @@ const delete_chat_messages = (seqs) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let locale = {};
|
||||||
let users = {};
|
let users = {};
|
||||||
let stats = null;
|
let stats = null;
|
||||||
let stats_received = null;
|
let stats_received = null;
|
||||||
|
@ -438,23 +442,23 @@ const chat_form_captcha_answer = document.getElementById("chat-form_js__captcha-
|
||||||
chat_form_captcha_image.addEventListener("loadstart", (event) => {
|
chat_form_captcha_image.addEventListener("loadstart", (event) => {
|
||||||
chat_form_captcha_image.removeAttribute("title");
|
chat_form_captcha_image.removeAttribute("title");
|
||||||
chat_form_captcha_image.removeAttribute("data-reloadable");
|
chat_form_captcha_image.removeAttribute("data-reloadable");
|
||||||
chat_form_captcha_image.alt = "Loading...";
|
chat_form_captcha_image.alt = locale.loading || "Loading...";
|
||||||
});
|
});
|
||||||
chat_form_captcha_image.addEventListener("load", (event) => {
|
chat_form_captcha_image.addEventListener("load", (event) => {
|
||||||
chat_form_captcha_image.removeAttribute("alt");
|
chat_form_captcha_image.removeAttribute("alt");
|
||||||
chat_form_captcha_image.dataset.reloadable = "";
|
chat_form_captcha_image.dataset.reloadable = "";
|
||||||
chat_form_captcha_image.title = "Click for a new captcha";
|
chat_form_captcha_image.title = locale.click_for_a_new_captcha || "Click for a new captcha";
|
||||||
});
|
});
|
||||||
chat_form_captcha_image.addEventListener("error", (event) => {
|
chat_form_captcha_image.addEventListener("error", (event) => {
|
||||||
chat_form_captcha_image.alt = "Captcha failed to load";
|
chat_form_captcha_image.alt = locale.captcha_failed_to_load || "Captcha failed to load";
|
||||||
chat_form_captcha_image.dataset.reloadable = "";
|
chat_form_captcha_image.dataset.reloadable = "";
|
||||||
chat_form_captcha_image.title = "Click for a new captcha";
|
chat_form_captcha_image.title = locale.click_for_a_new_captcha || "Click for a new captcha";
|
||||||
});
|
});
|
||||||
chat_form_captcha_image.addEventListener("click", (event) => {
|
chat_form_captcha_image.addEventListener("click", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (chat_form_captcha_image.dataset.reloadable !== undefined) {
|
if (chat_form_captcha_image.dataset.reloadable !== undefined) {
|
||||||
chat_form_submit.disabled = true;
|
chat_form_submit.disabled = true;
|
||||||
chat_form_captcha_image.alt = "Waiting...";
|
chat_form_captcha_image.alt = locale.waiting || "Waiting...";
|
||||||
chat_form_captcha_image.removeAttribute("title");
|
chat_form_captcha_image.removeAttribute("title");
|
||||||
chat_form_captcha_image.removeAttribute("data-reloadable");
|
chat_form_captcha_image.removeAttribute("data-reloadable");
|
||||||
chat_form_captcha_image.removeAttribute("src");
|
chat_form_captcha_image.removeAttribute("src");
|
||||||
|
@ -518,7 +522,7 @@ const update_uptime = () => {
|
||||||
setInterval(update_uptime, 1000); // always update uptime
|
setInterval(update_uptime, 1000); // always update uptime
|
||||||
|
|
||||||
const update_viewership = () => {
|
const update_viewership = () => {
|
||||||
info_viewership.innerText = stats === null ? "" : `${stats.viewership} viewers`;
|
info_viewership.innerText = stats === null ? "" : (locale.viewers || "{0} viewers").replace('{0}', stats.viewership);
|
||||||
}
|
}
|
||||||
|
|
||||||
const update_stats = () => {
|
const update_stats = () => {
|
||||||
|
@ -564,7 +568,7 @@ const update_users_list = () => {
|
||||||
}
|
}
|
||||||
if (is_you) {
|
if (is_you) {
|
||||||
const you = document.createElement("span");
|
const you = document.createElement("span");
|
||||||
you.innerText = " (You)";
|
you.innerText = locale.you || " (You)";
|
||||||
chat_user.insertAdjacentElement("beforeend", you);
|
chat_user.insertAdjacentElement("beforeend", you);
|
||||||
}
|
}
|
||||||
chat_users_sublist.insertAdjacentElement("beforeend", chat_user);
|
chat_users_sublist.insertAdjacentElement("beforeend", chat_user);
|
||||||
|
@ -584,8 +588,8 @@ const update_users_list = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// show correct numbers
|
// show correct numbers
|
||||||
chat_users_watching_header.innerText = `Watching (${watching})`;
|
chat_users_watching_header.innerText = (locale.watching || "Watching ({0})").replace("{0}", watching);
|
||||||
chat_users_notwatching_header.innerText = `Not watching (${notwatching})`;
|
chat_users_notwatching_header.innerText = (locale.not_watching || "Not watching ({0})").replace("{0}", notwatching);
|
||||||
}
|
}
|
||||||
|
|
||||||
const show_offline_screen = () => {
|
const show_offline_screen = () => {
|
||||||
|
@ -608,6 +612,21 @@ const on_websocket_message = async (event) => {
|
||||||
console.log("ws init", receipt);
|
console.log("ws init", receipt);
|
||||||
|
|
||||||
pingpong_period = receipt.pingpong;
|
pingpong_period = receipt.pingpong;
|
||||||
|
|
||||||
|
// update locale & put localized strings in js-inserted elements
|
||||||
|
locale = receipt.locale;
|
||||||
|
for (element of document.querySelectorAll('[data-string]')) {
|
||||||
|
const string = element.dataset.string;
|
||||||
|
if (locale[string] !== undefined) {
|
||||||
|
const attr = element.dataset.stringAttr;
|
||||||
|
if (attr === undefined)
|
||||||
|
element.innerText = locale[string];
|
||||||
|
else
|
||||||
|
element[attr] = locale[string];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stream title
|
||||||
set_title(receipt.title);
|
set_title(receipt.title);
|
||||||
|
|
||||||
// update stats (uptime/viewership)
|
// update stats (uptime/viewership)
|
||||||
|
@ -813,7 +832,7 @@ const on_websocket_message = async (event) => {
|
||||||
ul.insertAdjacentElement("beforeend", li);
|
ul.insertAdjacentElement("beforeend", li);
|
||||||
}
|
}
|
||||||
const result = document.createElement("div");
|
const result = document.createElement("div");
|
||||||
result.innerText = "Errors:";
|
result.innerText = locale.errors || "Errors:";
|
||||||
result.insertAdjacentElement("beforeend", ul);
|
result.insertAdjacentElement("beforeend", ul);
|
||||||
chat_appearance_form_result.innerHTML = result.innerHTML;
|
chat_appearance_form_result.innerHTML = result.innerHTML;
|
||||||
}
|
}
|
||||||
|
@ -850,14 +869,14 @@ const connect_websocket = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chat_live_ball.style.borderColor = "gold";
|
chat_live_ball.style.borderColor = "gold";
|
||||||
chat_live_status.innerHTML = "<span data-verbose='true'>Connecting to chat...</span><span data-verbose='false'>···</span>";
|
chat_live_status.innerHTML = `<span data-verbose='true'>${locale.connecting_to_chat || "Connecting to chat..."}</span><span data-verbose='false'>···</span>`;
|
||||||
ws = null;
|
ws = null;
|
||||||
ws = new WebSocket(`ws://${document.domain}:${location.port}/live?token=${encodeURIComponent(TOKEN)}`);
|
ws = new WebSocket(`ws://${document.domain}:${location.port}/live?token=${encodeURIComponent(TOKEN)}&lang=${encodeURIComponent(LANG)}`);
|
||||||
ws.addEventListener("open", (event) => {
|
ws.addEventListener("open", (event) => {
|
||||||
console.log("websocket open", event);
|
console.log("websocket open", event);
|
||||||
chat_form_submit.disabled = false;
|
chat_form_submit.disabled = false;
|
||||||
chat_live_ball.style.borderColor = "green";
|
chat_live_ball.style.borderColor = "green";
|
||||||
chat_live_status.innerHTML = "<span><span data-verbose='true'>Connected to chat</span><span data-verbose='false'>✓</span></span>";
|
chat_live_status.innerHTML = `<span><span data-verbose='true'>${locale.connected_to_chat || "Connected to chat"}</span><span data-verbose='false'>✓</span></span>`;
|
||||||
// When the server is offline, a newly opened websocket can take a second
|
// When the server is offline, a newly opened websocket can take a second
|
||||||
// to close. This timeout tries to ensure the backoff doesn't instantly
|
// to close. This timeout tries to ensure the backoff doesn't instantly
|
||||||
// (erroneously) reset to 2 seconds in that case.
|
// (erroneously) reset to 2 seconds in that case.
|
||||||
|
@ -873,7 +892,7 @@ const connect_websocket = () => {
|
||||||
console.log("websocket close", event);
|
console.log("websocket close", event);
|
||||||
chat_form_submit.disabled = true;
|
chat_form_submit.disabled = true;
|
||||||
chat_live_ball.style.borderColor = "maroon";
|
chat_live_ball.style.borderColor = "maroon";
|
||||||
chat_live_status.innerHTML = "<span data-verbose='true'>Disconnected from chat</span><span data-verbose='false'>×</span>";
|
chat_live_status.innerHTML = `<span data-verbose='true'>${locale.disconnected_from_chat || "Disconnected from chat"}</span><span data-verbose='false'>×</span>`;
|
||||||
if (!ws.successor) {
|
if (!ws.successor) {
|
||||||
ws.successor = true;
|
ws.successor = true;
|
||||||
setTimeout(connect_websocket, websocket_backoff);
|
setTimeout(connect_websocket, websocket_backoff);
|
||||||
|
@ -884,7 +903,7 @@ const connect_websocket = () => {
|
||||||
console.log("websocket error", event);
|
console.log("websocket error", event);
|
||||||
chat_form_submit.disabled = true;
|
chat_form_submit.disabled = true;
|
||||||
chat_live_ball.style.borderColor = "maroon";
|
chat_live_ball.style.borderColor = "maroon";
|
||||||
chat_live_status.innerHTML = "<span>Error<span data-verbose='true'> connecting to chat</span></span>";
|
chat_live_status.innerHTML = `<span><span data-verbose='true'>${locale.error_connecting_to_chat || "Error connecting to chat"}</span><span data-verbose='false'>${locale.error_connecting_to_chat_terse || "Error"}</span></span>`;
|
||||||
});
|
});
|
||||||
ws.addEventListener("message", on_websocket_message);
|
ws.addEventListener("message", on_websocket_message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<img src="{{ url_for('captcha', digest=digest) }}" width="72" height="30">
|
<img src="{{ url_for('captcha', digest=digest) }}" width="72" height="30">
|
||||||
<form action="{{ url_for('access', token=token) }}" method="post">
|
<form action="{{ url_for('access', token=token, lang=request_lang) }}" method="post">
|
||||||
<input type="hidden" name="digest" value="{{ digest }}">
|
<input type="hidden" name="digest" value="{{ digest }}">
|
||||||
<input name="answer" placeholder="Captcha" required autofocus>
|
<input name="answer" placeholder="{{ locale.captcha }}" required autofocus>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
{% if failure is not none %}<p>{{ failure }}</p>{% endif %}
|
{% if failure is not none %}<p>{{ failure }}</p>{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{ error.code }} {{ error.name }}</title>
|
<title>{{ error.code }} {{ locale[error.code | string] or error.name }}</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background-color: #232327;
|
background-color: #232327;
|
||||||
|
@ -63,8 +63,8 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h1>{{ error.name }}</h1>
|
<h1>{{ locale[error.code | string] or error.name }}</h1>
|
||||||
{% if error.description != error.__class__.description %}
|
{% if error.description is not none %}
|
||||||
<p>{{ error.description }}</p>
|
<p>{{ error.description }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -3,45 +3,45 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
##}
|
##}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html id="nochat">
|
<html id="nochat" lang="{{ lang or default_lang }}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="content-security-policy" content="default-src 'none'; connect-src 'self'; img-src 'self'; frame-src 'self'; media-src 'self'; script-src 'self'; style-src 'self' 'nonce-{{ csp }}';">
|
<meta http-equiv="content-security-policy" content="default-src 'none'; connect-src 'self'; img-src 'self'; frame-src 'self'; media-src 'self'; script-src 'self'; style-src 'self' 'nonce-{{ csp }}';">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" type="text/css">
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css', token=user.token) }}" type="text/css">
|
||||||
</head>
|
</head>
|
||||||
<body id="both" data-token="{{ user.token }}" data-token-hash="{{ user.token_hash }}" data-csp="{{ csp }}">
|
<body id="both" data-token="{{ user.token }}" data-token-hash="{{ user.token_hash }}" data-csp="{{ csp }}">
|
||||||
<article id="stream">
|
<article id="stream">
|
||||||
<noscript><iframe id="stream_nojs" name="stream_nojs" src="{{ url_for('nojs_stream', token=user.token) }}"></iframe></noscript>
|
<noscript><iframe id="stream_nojs" name="stream_nojs" src="{{ url_for('nojs_stream', token=user.token) }}"></iframe></noscript>
|
||||||
</article>
|
</article>
|
||||||
<article id="info">
|
<article id="info">
|
||||||
<noscript><iframe id="info_nojs" src="{{ url_for('nojs_info', token=user.token) }}" data-js="false"></iframe></noscript>
|
<noscript><iframe id="info_nojs" src="{{ url_for('nojs_info', token=user.token, lang=lang) }}" data-js="false"></iframe></noscript>
|
||||||
</article>
|
</article>
|
||||||
<aside id="chat">
|
<aside id="chat">
|
||||||
<input id="chat__toggle" type="checkbox">
|
<input id="chat__toggle" type="checkbox">
|
||||||
<header id="chat__header">
|
<header id="chat__header">
|
||||||
<label id="chat__header__button" for="chat__toggle">Users</label>
|
<label id="chat__header__button" for="chat__toggle">{{ locale.users }}</label>
|
||||||
<h3 id="chat__header__text">Stream chat</h3>
|
<h3 id="chat__header__text">{{ locale.stream_chat }}</h3>
|
||||||
</header>
|
</header>
|
||||||
<article id="chat__body">
|
<article id="chat__body">
|
||||||
<section id="chat__body__messages">
|
<section id="chat__body__messages">
|
||||||
<noscript><iframe id="chat-messages_nojs" src="{{ url_for('nojs_chat_messages', token=user.token, _anchor='end') }}" data-js="false"></iframe></noscript>
|
<noscript><iframe id="chat-messages_nojs" src="{{ url_for('nojs_chat_messages', token=user.token, lang=lang, _anchor='end') }}" data-js="false"></iframe></noscript>
|
||||||
</section>
|
</section>
|
||||||
<section id="chat__body__users">
|
<section id="chat__body__users">
|
||||||
<header id="chat-users-header"><h4>Users in chat</h4></header>
|
<header id="chat-users-header"><h4>{{ locale.users_in_chat }}</h4></header>
|
||||||
<noscript><iframe id="chat-users_nojs" src="{{ url_for('nojs_chat_users', token=user.token) }}" data-js="false"></iframe></noscript>
|
<noscript><iframe id="chat-users_nojs" src="{{ url_for('nojs_chat_users', token=user.token, lang=lang) }}" data-js="false"></iframe></noscript>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
<section id="chat__form">
|
<section id="chat__form">
|
||||||
<noscript><iframe id="chat-form_nojs" src="{{ url_for('nojs_chat_form', token=user.token) }}" data-js="false"></iframe></noscript>
|
<noscript><iframe id="chat-form_nojs" src="{{ url_for('nojs_chat_form', token=user.token, lang=lang) }}" data-js="false"></iframe></noscript>
|
||||||
</section>
|
</section>
|
||||||
</aside>
|
</aside>
|
||||||
<nav id="nav">
|
<nav id="nav">
|
||||||
<a href="#info">info</a>
|
<a href="#info">{{ locale.info }}</a>
|
||||||
<a href="#chat">chat</a>
|
<a href="#chat">{{ locale.chat }}</a>
|
||||||
<a href="#both">both</a>
|
<a href="#both">{{ locale.both }}</a>
|
||||||
</nav>
|
</nav>
|
||||||
<footer>anonstream {{ version }} — <a href="https://git.076.ne.jp/ninya9k/anonstream" target="_blank">source</a></footer>
|
<footer>anonstream {{ version }} — <a href="https://git.076.ne.jp/ninya9k/anonstream" target="_blank">{{ locale.source }}</a></footer>
|
||||||
<script src="{{ url_for('static', filename='anonstream.js') }}" type="text/javascript"></script>
|
<script src="{{ url_for('static', filename='anonstream.js', token=user.token) }}" type="text/javascript"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
#appearance-form__buttons {
|
#appearance-form__buttons {
|
||||||
grid-column: 1 / span 3;
|
grid-column: 1 / span 3;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 5rem;
|
grid-template-columns: auto 6rem;
|
||||||
}
|
}
|
||||||
#password-column {
|
#password-column {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
@ -214,45 +214,50 @@
|
||||||
<input id="toggle" type="checkbox" {% if not prefer_chat_form %}checked {% endif %}accesskey="x">
|
<input id="toggle" type="checkbox" {% if not prefer_chat_form %}checked {% endif %}accesskey="x">
|
||||||
{% if state.notice %}
|
{% if state.notice %}
|
||||||
<input id="notice-radio" type="radio" accesskey="z">
|
<input id="notice-radio" type="radio" accesskey="z">
|
||||||
<label id="notice" for="notice-radio"{% if state.verbose %} class="verbose"{% endif %}>
|
<label id="notice" for="notice-radio"{% if (state.notice | length) > 1 %} class="verbose"{% endif %}>
|
||||||
<header><h2>{{ state.notice }}</h2></header>
|
<header><h2>
|
||||||
<small>Click to dismiss</small>
|
{%- for string, args in state.notice %}
|
||||||
|
{{ locale.internal[string] | escape | format(*args) -}}
|
||||||
|
{% if not loop.last %}<br>{% endif %}
|
||||||
|
{% endfor -%}
|
||||||
|
</h2></header>
|
||||||
|
<small>{{ locale.form.click_to_dismiss }}</small>
|
||||||
</label>
|
</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<form id="chat-form" action="{{ url_for('nojs_submit_message', token=user.token) }}" method="post">
|
<form id="chat-form" action="{{ url_for('nojs_submit_message', token=user.token, lang=lang) }}" method="post">
|
||||||
<input type="hidden" name="nonce" value="{{ nonce }}">
|
<input type="hidden" name="nonce" value="{{ nonce }}">
|
||||||
<textarea id="chat-form__comment" name="comment" maxlength="{{ max_comment_length }}" {% if digest is none %}required {% endif %} placeholder="Send a message..." rows="1" tabindex="1" autofocus accesskey="m">{{ state.comment }}</textarea>
|
<textarea id="chat-form__comment" name="comment" maxlength="{{ max_comment_length }}" {% if digest is none %}required {% endif %} placeholder="{{ locale.form.send_a_message }}" rows="1" tabindex="1" autofocus accesskey="m">{{ state.comment }}</textarea>
|
||||||
<input id="chat-form__submit" type="submit" value="Chat" tabindex="4" accesskey="p">
|
<input id="chat-form__submit" type="submit" value="{{ locale.form.chat }}" tabindex="4" accesskey="p">
|
||||||
<div id="chat-form__exit"><label for="toggle" class="pseudolink">Settings</label></div>
|
<div id="chat-form__exit"><label for="toggle" class="pseudolink">{{ locale.form.settings }}</label></div>
|
||||||
{% if digest %}
|
{% if digest %}
|
||||||
<input type="hidden" name="captcha-digest" value="{{ digest }}">
|
<input type="hidden" name="captcha-digest" value="{{ digest }}">
|
||||||
<input id="chat-form__captcha-image" type="image" formaction="{{ url_for('nojs_chat_form_redirect', token=user.token) }}" formnovalidate src="{{ url_for('captcha', token=user.token, digest=digest) }}" width="72" height="30" alt="Captcha failed to load" title="Click for a new captcha" tabindex="2">
|
<input id="chat-form__captcha-image" type="image" formaction="{{ url_for('nojs_chat_form_redirect', token=user.token) }}" formnovalidate src="{{ url_for('captcha', token=user.token, digest=digest) }}" width="72" height="30" alt="{{ locale.form.captcha_failed_to_load }}" title="{{ locale.form.click_for_a_new_captcha }}" tabindex="2">
|
||||||
<input id="chat-form__captcha-answer" name="captcha-answer" required placeholder="Captcha" tabindex="3">
|
<input id="chat-form__captcha-answer" name="captcha-answer" required placeholder="Captcha" tabindex="3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
<form id="appearance-form" action="{{ url_for('nojs_submit_appearance', token=user.token) }}" method="post">
|
<form id="appearance-form" action="{{ url_for('nojs_submit_appearance', token=user.token, lang=lang) }}" method="post">
|
||||||
<label id="appearance-form__label-name" for="appearance-form__name">Name:</label>
|
<label id="appearance-form__label-name" for="appearance-form__name">{{ locale.form.name }}</label>
|
||||||
<input id="appearance-form__name" name="name" value="{{ user.name or '' }}" placeholder="{{ default_name }}" maxlength="{{ max_name_length }}">
|
<input id="appearance-form__name" name="name" value="{{ user.name or '' }}" placeholder="{{ default_name }}" maxlength="{{ max_name_length }}">
|
||||||
<input type="color" name="color" value="{{ user.color }}">
|
<input type="color" name="color" value="{{ user.color }}">
|
||||||
<label id="appearance-form__label-password" for="appearance-form__password">Tripcode:</label>
|
<label id="appearance-form__label-password" for="appearance-form__password">{{ locale.form.tripcode }}</label>
|
||||||
<input id="password-toggle" name="set-tripcode" type="checkbox" accesskey="s">
|
<input id="password-toggle" name="set-tripcode" type="checkbox" accesskey="s">
|
||||||
<input id="cleared-toggle" name="clear-tripcode" type="checkbox"{% if user.tripcode != none %} accesskey="c"{% endif %}>
|
<input id="cleared-toggle" name="clear-tripcode" type="checkbox"{% if user.tripcode != none %} accesskey="c"{% endif %}>
|
||||||
<div id="password-column">
|
<div id="password-column">
|
||||||
{% if user.tripcode is none %}
|
{% if user.tripcode is none %}
|
||||||
<span class="tripcode">(no tripcode)</span>
|
<span class="tripcode">{{ locale.form.no_tripcode }}</span>
|
||||||
<label for="password-toggle" class="show-password pseudolink">set</label>
|
<label for="password-toggle" class="show-password pseudolink">{{ locale.form.set }}</label>
|
||||||
{% else %}
|
{% else %}
|
||||||
<label id="tripcode" for="password-toggle" class="show-password tripcode">{{ user.tripcode.digest }}</label>
|
<label id="tripcode" for="password-toggle" class="show-password tripcode">{{ user.tripcode.digest }}</label>
|
||||||
<label id="show-cleared" for="cleared-toggle" class="pseudolink x">×</label>
|
<label id="show-cleared" for="cleared-toggle" class="pseudolink x">×</label>
|
||||||
<div id="cleared" class="tripcode">(cleared)</div>
|
<div id="cleared" class="tripcode">{{ locale.form.cleared }}</div>
|
||||||
<label id="hide-cleared" for="cleared-toggle" class="pseudolink">undo</label>
|
<label id="hide-cleared" for="cleared-toggle" class="pseudolink">{{ locale.form.undo }}</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<input id="appearance-form__password" name="password" type="password" placeholder="(tripcode password)" maxlength="{{ max_password_length }}">
|
<input id="appearance-form__password" name="password" type="password" placeholder="{{ locale.form.tripcode_password }}" maxlength="{{ max_password_length }}">
|
||||||
<div id="hide-password"><label for="password-toggle" class="pseudolink x">×</label></div>
|
<div id="hide-password"><label for="password-toggle" class="pseudolink x">×</label></div>
|
||||||
<div id="appearance-form__buttons">
|
<div id="appearance-form__buttons">
|
||||||
<div id="appearance-form__buttons__exit"><label for="toggle" class="pseudolink">Return to chat</label></div>
|
<div id="appearance-form__buttons__exit"><label for="toggle" class="pseudolink">{{ locale.form.return_to_chat }}</label></div>
|
||||||
<input type="submit" value="Update">
|
<input type="submit" value="{{ locale.form['update'] }}">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -165,8 +165,8 @@
|
||||||
<div id="notimeout"></div>
|
<div id="notimeout"></div>
|
||||||
<aside id="timeout">
|
<aside id="timeout">
|
||||||
<a class="button" href="{{ url_for('nojs_chat_messages_redirect', token=user.token) }}">
|
<a class="button" href="{{ url_for('nojs_chat_messages_redirect', token=user.token) }}">
|
||||||
<header>Timed out</header>
|
<header>{{ locale.timed_out }}</header>
|
||||||
<small>Click to refresh</small>
|
<small>{{ locale.click_to_refresh }}</small>
|
||||||
</a>
|
</a>
|
||||||
</aside>
|
</aside>
|
||||||
<ol id="chat-messages">
|
<ol id="chat-messages">
|
||||||
|
@ -183,10 +183,10 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
<aside id="timeout-dismiss">
|
<aside id="timeout-dismiss">
|
||||||
<a class="button" href="#notimeout">Hide timeout notice</a>
|
<a class="button" href="#notimeout">{{ locale.hide_timeout_notice }}</a>
|
||||||
</aside>
|
</aside>
|
||||||
<aside id="timeout-alt">
|
<aside id="timeout-alt">
|
||||||
<a class="button" href="{{ url_for('nojs_chat_messages_redirect', token=user.token) }}">Click to refresh</a>
|
<a class="button" href="{{ url_for('nojs_chat_messages_redirect', token=user.token) }}">{{ locale.click_to_refresh }}</a>
|
||||||
</aside>
|
</aside>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -109,27 +109,27 @@
|
||||||
<body>
|
<body>
|
||||||
<aside id="timeout">
|
<aside id="timeout">
|
||||||
<a href="">
|
<a href="">
|
||||||
<header>Timed out</header>
|
<header>{{ locale.timed_out}} </header>
|
||||||
<small>Click to refresh</small>
|
<small>{{ locale.click_to_refresh }}</small>
|
||||||
</a>
|
</a>
|
||||||
</aside>
|
</aside>
|
||||||
<main id="main">
|
<main id="main">
|
||||||
<h5>Watching ({{ users_watching | length }})</h5>
|
<h5>{{ locale.watching | format(users_watching | length) }}</h5>
|
||||||
<ul>
|
<ul>
|
||||||
{% for user_listed in users_watching %}
|
{% for user_listed in users_watching %}
|
||||||
<li class="user" data-token-hash="{{ user_listed.token_hash }}">
|
<li class="user" data-token-hash="{{ user_listed.token_hash }}">
|
||||||
{{- appearance(user_listed, insignia_class='user__insignia', name_class='user__name', tag_class='user__name__tag') -}}
|
{{- appearance(user_listed, insignia_class='user__insignia', name_class='user__name', tag_class='user__name__tag') -}}
|
||||||
{%- if user.token == user_listed.token %} (You){% endif -%}
|
{%- if user.token == user_listed.token %}{{ locale.you }}{% endif -%}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
<h5>Not watching ({{ users_notwatching | length }})</h5>
|
<h5>{{ locale.not_watching | format(users_notwatching | length) }}</h5>
|
||||||
<ul>
|
<ul>
|
||||||
{% for user_listed in users_notwatching %}
|
{% for user_listed in users_notwatching %}
|
||||||
<li class="user" data-token-hash="{{ user_listed.token_hash }}">
|
<li class="user" data-token-hash="{{ user_listed.token_hash }}">
|
||||||
{{- appearance(user_listed, insignia_class='user__insignia', name_class='user__name', tag_class='user__name__tag') -}}
|
{{- appearance(user_listed, insignia_class='user__insignia', name_class='user__name', tag_class='user__name__tag') -}}
|
||||||
{%- if user.token == user_listed.token %} (You){% endif -%}
|
{%- if user.token == user_listed.token %}{{ locale.you }}{% endif -%}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -144,13 +144,13 @@
|
||||||
{% if user.presence != Presence.WATCHING %}
|
{% if user.presence != Presence.WATCHING %}
|
||||||
<form id="float__form" action="{{ url_for('nojs_stream') }}" target="stream_nojs">
|
<form id="float__form" action="{{ url_for('nojs_stream') }}" target="stream_nojs">
|
||||||
<input type="hidden" name="token" value="{{ user.token }}">
|
<input type="hidden" name="token" value="{{ user.token }}">
|
||||||
<input type="submit" value="Reload stream" accesskey="r">
|
<input type="submit" value="{{ locale.reload_stream }}" accesskey="r">
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div id="float__viewership">{{ viewership }} viewers</div>
|
<div id="float__viewership">{{ locale.viewers | format(viewership) }}</div>
|
||||||
<div id="float__uptime">
|
<div id="float__uptime">
|
||||||
<div id="uptime-static"{% if uptime < 360000 %} data-hidden=""{% endif %}>
|
<div id="uptime-static"{% if uptime < 360000 %} data-hidden=""{% endif %}>
|
||||||
<span id="uptime-static__label">Uptime:</span>
|
<span id="uptime-static__label">{{ locale.uptime }}</span>
|
||||||
<span>
|
<span>
|
||||||
{%- if uptime >= 3600 -%}
|
{%- if uptime >= 3600 -%}
|
||||||
{{- uptime | int // 3600 -}}
|
{{- uptime | int // 3600 -}}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
{% if online %}
|
{% if online %}
|
||||||
<video id="video" src="{{ url_for('stream', token=user.token) }}" autoplay controls></video>
|
<video id="video" src="{{ url_for('stream', token=user.token) }}" autoplay controls></video>
|
||||||
{% else %}
|
{% else %}
|
||||||
<header id="offline"><h1>[offline]</h1></header>
|
<header id="offline"><h1>{{ locale.offline }}</h1></header>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,7 +6,7 @@ import time
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from math import inf
|
from math import inf
|
||||||
|
|
||||||
from quart import current_app
|
from quart import current_app, Markup
|
||||||
|
|
||||||
from anonstream.wrappers import try_except_log, with_timestamp, get_timestamp
|
from anonstream.wrappers import try_except_log, with_timestamp, get_timestamp
|
||||||
from anonstream.helpers.user import get_default_name, get_presence, Presence
|
from anonstream.helpers.user import get_default_name, get_presence, Presence
|
||||||
|
@ -106,10 +106,11 @@ def change_name(user, name, dry_run=False):
|
||||||
name = None
|
name = None
|
||||||
if name is not None:
|
if name is not None:
|
||||||
if len(name) == 0:
|
if len(name) == 0:
|
||||||
raise BadAppearance('Name was empty')
|
raise BadAppearance('name_empty')
|
||||||
if len(name) > CONFIG['CHAT_NAME_MAX_LENGTH']:
|
if len(name) > CONFIG['CHAT_NAME_MAX_LENGTH']:
|
||||||
raise BadAppearance(
|
raise BadAppearance(
|
||||||
f'Name exceeded {CONFIG["CHAT_NAME_MAX_LENGTH"]} chars'
|
'name_too_long',
|
||||||
|
CONFIG['CHAT_NAME_MAX_LENGTH'],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
user['name'] = name
|
user['name'] = name
|
||||||
|
@ -119,16 +120,13 @@ def change_color(user, color, dry_run=False):
|
||||||
try:
|
try:
|
||||||
colour = color_to_colour(color)
|
colour = color_to_colour(color)
|
||||||
except NotAColor:
|
except NotAColor:
|
||||||
raise BadAppearance('Invalid CSS color')
|
raise BadAppearance('colour_invalid_css')
|
||||||
contrast = get_contrast(
|
contrast = get_contrast(CONFIG['CHAT_BACKGROUND_COLOUR'], colour)
|
||||||
CONFIG['CHAT_BACKGROUND_COLOUR'],
|
|
||||||
colour,
|
|
||||||
)
|
|
||||||
min_contrast = CONFIG['CHAT_NAME_MIN_CONTRAST']
|
min_contrast = CONFIG['CHAT_NAME_MIN_CONTRAST']
|
||||||
if contrast < min_contrast:
|
if contrast < min_contrast:
|
||||||
raise BadAppearance(
|
raise BadAppearance(
|
||||||
'Colour had insufficient contrast:',
|
'colour_insufficient_contrast',
|
||||||
(f'{contrast:.2f}', f'/{min_contrast:.2f}'),
|
Markup(f'<mark>{contrast:.2f}</mark>/{min_contrast:.2f}'),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
user['color'] = color
|
user['color'] = color
|
||||||
|
@ -137,8 +135,8 @@ def change_tripcode(user, password, dry_run=False):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
if len(password) > CONFIG['CHAT_TRIPCODE_PASSWORD_MAX_LENGTH']:
|
if len(password) > CONFIG['CHAT_TRIPCODE_PASSWORD_MAX_LENGTH']:
|
||||||
raise BadAppearance(
|
raise BadAppearance(
|
||||||
f'Password exceeded '
|
'password_too_long',
|
||||||
f'{CONFIG["CHAT_TRIPCODE_PASSWORD_MAX_LENGTH"]} chars'
|
CONFIG['CHAT_TRIPCODE_PASSWORD_MAX_LENGTH'],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
user['tripcode'] = generate_tripcode(password)
|
user['tripcode'] = generate_tripcode(password)
|
||||||
|
@ -176,11 +174,11 @@ def verify(user, digest, answer):
|
||||||
else:
|
else:
|
||||||
match check_captcha_digest(CAPTCHA_SIGNER, digest, answer):
|
match check_captcha_digest(CAPTCHA_SIGNER, digest, answer):
|
||||||
case Answer.MISSING:
|
case Answer.MISSING:
|
||||||
raise BadCaptcha('Captcha is required')
|
raise BadCaptcha('captcha_required')
|
||||||
case Answer.BAD:
|
case Answer.BAD:
|
||||||
raise BadCaptcha('Captcha was incorrect')
|
raise BadCaptcha('captcha_incorrect')
|
||||||
case Answer.EXPIRED:
|
case Answer.EXPIRED:
|
||||||
raise BadCaptcha('Captcha has expired')
|
raise BadCaptcha('captcha_expired')
|
||||||
case Answer.OK:
|
case Answer.OK:
|
||||||
user['verified'] = True
|
user['verified'] = True
|
||||||
verification_happened = True
|
verification_happened = True
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
import types
|
||||||
|
|
||||||
|
SPEC = {
|
||||||
|
'anonstream': {
|
||||||
|
'error': {
|
||||||
|
'invalid_token': str,
|
||||||
|
'captcha': str,
|
||||||
|
'captcha_again': str,
|
||||||
|
'impostor': str,
|
||||||
|
'broadcaster_should_log_in': str,
|
||||||
|
'wrong_username_or_password': str,
|
||||||
|
'blacklisted': str,
|
||||||
|
'not_whitelisted': str,
|
||||||
|
'offline': str,
|
||||||
|
'ratelimit': str,
|
||||||
|
'limit': str,
|
||||||
|
},
|
||||||
|
'internal': {
|
||||||
|
'captcha_required': str,
|
||||||
|
'captcha_incorrect': str,
|
||||||
|
'captcha_expired': str,
|
||||||
|
'message_ratelimited': str,
|
||||||
|
'message_suspected_duplicate': str,
|
||||||
|
'message_empty': str,
|
||||||
|
'message_practically_empty': str,
|
||||||
|
'message_too_long': str,
|
||||||
|
'message_too_many_lines': str,
|
||||||
|
'message_too_many_apparent_lines': str,
|
||||||
|
'appearance_changed': str,
|
||||||
|
'name_empty': str,
|
||||||
|
'name_too_long': str,
|
||||||
|
'colour_invalid_css': str,
|
||||||
|
'colour_insufficient_contrast': str,
|
||||||
|
'password_too_long': str,
|
||||||
|
},
|
||||||
|
'captcha': {
|
||||||
|
'captcha_failed_to_load': str,
|
||||||
|
'click_for_a_new_captcha': str,
|
||||||
|
},
|
||||||
|
'home': {
|
||||||
|
'info': str,
|
||||||
|
'chat': str,
|
||||||
|
'both': str,
|
||||||
|
'source': str,
|
||||||
|
'users': str,
|
||||||
|
'users_in_chat': str,
|
||||||
|
'stream_chat': str,
|
||||||
|
},
|
||||||
|
'stream': {
|
||||||
|
'offline': str,
|
||||||
|
},
|
||||||
|
'info': {
|
||||||
|
'viewers': str,
|
||||||
|
'uptime': str,
|
||||||
|
'reload_stream': str,
|
||||||
|
},
|
||||||
|
'chat': {
|
||||||
|
'users': str,
|
||||||
|
'click_to_refresh': str,
|
||||||
|
'hide_timeout_notice': str,
|
||||||
|
'watching': str,
|
||||||
|
'not_watching': str,
|
||||||
|
'you': str,
|
||||||
|
'timed_out': str,
|
||||||
|
},
|
||||||
|
'form': {
|
||||||
|
'click_to_dismiss': str,
|
||||||
|
'send_a_message': str,
|
||||||
|
'captcha': str,
|
||||||
|
'settings': str,
|
||||||
|
'captcha_failed_to_load': str,
|
||||||
|
'click_for_a_new_captcha': str,
|
||||||
|
'chat': str,
|
||||||
|
'name': str,
|
||||||
|
'tripcode': str,
|
||||||
|
'no_tripcode': str,
|
||||||
|
'set': str,
|
||||||
|
'cleared': str,
|
||||||
|
'undo': str,
|
||||||
|
'tripcode_password': str,
|
||||||
|
'return_to_chat': str,
|
||||||
|
'update': str,
|
||||||
|
},
|
||||||
|
'js': {
|
||||||
|
'offline': str,
|
||||||
|
'reload_stream': str,
|
||||||
|
'chat_scroll_paused': str,
|
||||||
|
'not_connected': str,
|
||||||
|
'broadcaster': str,
|
||||||
|
'loading': str,
|
||||||
|
'click_for_a_new_captcha': str,
|
||||||
|
'viewers': str,
|
||||||
|
'you': str,
|
||||||
|
'watching': str,
|
||||||
|
'not_watching': str,
|
||||||
|
'errors': str,
|
||||||
|
'connecting_to_chat': str,
|
||||||
|
'connected_to_chat': str,
|
||||||
|
'disconnected_from_chat': str,
|
||||||
|
'error_connecting_to_chat': str,
|
||||||
|
'error_connecting_to_chat_terse': str,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'http': {
|
||||||
|
'400': str | None,
|
||||||
|
'401': str | None,
|
||||||
|
'403': str | None,
|
||||||
|
'404': str | None,
|
||||||
|
'405': str | None,
|
||||||
|
'410': str | None,
|
||||||
|
'500': str | None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Nonconforming(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _conform_to_spec(data, spec, level=()):
|
||||||
|
assert isinstance(spec, dict), \
|
||||||
|
f'bad locale spec at {level}: must be {dict}, not {type(spec)}'
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
raise Nonconforming(
|
||||||
|
f'object at {level} must be dict, not {type(data)}'
|
||||||
|
)
|
||||||
|
missing_keys = set(spec.keys()) - set(data.keys())
|
||||||
|
if missing_keys:
|
||||||
|
raise Nonconforming(f'dict at {level} is missing keys {missing_keys}')
|
||||||
|
extra_keys = set(data.keys()) - set(spec.keys())
|
||||||
|
if extra_keys:
|
||||||
|
raise Nonconforming(f'dict at {level} has extra keys {extra_keys}')
|
||||||
|
for key, subspec in spec.items():
|
||||||
|
subdata = data[key]
|
||||||
|
if isinstance(subspec, dict):
|
||||||
|
_conform_to_spec(subdata, subspec, level + (key,))
|
||||||
|
else:
|
||||||
|
assert isinstance(subspec, type | types.UnionType), \
|
||||||
|
f'bad locale spec at {level + (key,)}: must be {dict | type}, not {type(subspec)}'
|
||||||
|
if not isinstance(subdata, subspec):
|
||||||
|
raise Nonconforming(
|
||||||
|
f'value at {level + (key,)} must be {subspec}, not {type(subdata)}'
|
||||||
|
)
|
||||||
|
|
||||||
|
def validate_locale(locale):
|
||||||
|
return _conform_to_spec(locale, SPEC)
|
|
@ -25,17 +25,6 @@ Presence = Enum(
|
||||||
def generate_token():
|
def generate_token():
|
||||||
return secrets.token_hex(16)
|
return secrets.token_hex(16)
|
||||||
|
|
||||||
def concatenate_for_notice(string, *tuples):
|
|
||||||
if not tuples:
|
|
||||||
return string
|
|
||||||
markup = Markup(
|
|
||||||
''.join(
|
|
||||||
f' <mark>{escape(x)}</mark>{escape(y)}'
|
|
||||||
for x, y in tuples
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return string + markup
|
|
||||||
|
|
||||||
def trilean(presence):
|
def trilean(presence):
|
||||||
match presence:
|
match presence:
|
||||||
case Presence.WATCHING:
|
case Presence.WATCHING:
|
||||||
|
|
|
@ -9,6 +9,7 @@ from quart import current_app, websocket
|
||||||
from anonstream.stream import get_stream_title, get_stream_uptime_and_viewership
|
from anonstream.stream import get_stream_title, get_stream_uptime_and_viewership
|
||||||
from anonstream.captcha import get_random_captcha_digest_for
|
from anonstream.captcha import get_random_captcha_digest_for
|
||||||
from anonstream.chat import get_all_messages_for_websocket, add_chat_message, Rejected
|
from anonstream.chat import get_all_messages_for_websocket, add_chat_message, Rejected
|
||||||
|
from anonstream.locale import get_locale_from
|
||||||
from anonstream.user import get_all_users_for_websocket, see, reading, verify, deverify, BadCaptcha, try_change_appearance, ensure_allowedness, AllowednessException
|
from anonstream.user import get_all_users_for_websocket, see, reading, verify, deverify, BadCaptcha, try_change_appearance, ensure_allowedness, AllowednessException
|
||||||
from anonstream.wrappers import with_timestamp, get_timestamp
|
from anonstream.wrappers import with_timestamp, get_timestamp
|
||||||
from anonstream.utils.chat import generate_nonce
|
from anonstream.utils.chat import generate_nonce
|
||||||
|
@ -36,6 +37,7 @@ async def websocket_outbound(queue, user):
|
||||||
'scrollback': CONFIG['MAX_CHAT_SCROLLBACK'],
|
'scrollback': CONFIG['MAX_CHAT_SCROLLBACK'],
|
||||||
'digest': get_random_captcha_digest_for(user),
|
'digest': get_random_captcha_digest_for(user),
|
||||||
'pingpong': CONFIG['TASK_BROADCAST_PING'],
|
'pingpong': CONFIG['TASK_BROADCAST_PING'],
|
||||||
|
'locale': get_locale_from(websocket)['anonstream']['js'],
|
||||||
})
|
})
|
||||||
while True:
|
while True:
|
||||||
payload = await queue.get()
|
payload = await queue.get()
|
||||||
|
@ -126,7 +128,7 @@ def handle_inbound_appearance(timestamp, queue, user, name, color, password, wan
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
'type': 'appearance',
|
'type': 'appearance',
|
||||||
'result': 'Changed appearance',
|
'result': 'Changed appearance' " [THIS STRING STILL HARDCODED]",
|
||||||
'name': user['name'],
|
'name': user['name'],
|
||||||
'color': user['color'],
|
'color': user['color'],
|
||||||
#'tripcode': user['tripcode'],
|
#'tripcode': user['tripcode'],
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
secret_key = "place secret key here"
|
secret_key = "place secret key here"
|
||||||
|
|
||||||
|
[locale]
|
||||||
|
default = "en"
|
||||||
|
offered = ["en", "de"]
|
||||||
|
directory = "l10n/"
|
||||||
|
|
||||||
[socket.control]
|
[socket.control]
|
||||||
enabled = true
|
enabled = true
|
||||||
address = "control.sock"
|
address = "control.sock"
|
||||||
|
@ -26,6 +31,7 @@ file_cache_lifetime = 0.5
|
||||||
|
|
||||||
[access]
|
[access]
|
||||||
captcha = true
|
captcha = true
|
||||||
|
hide_offered_locales = 0 #"don't" "from-new" "from-everyone"
|
||||||
|
|
||||||
[captcha]
|
[captcha]
|
||||||
lifetime = 1800
|
lifetime = 1800
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
{
|
||||||
|
"anonstream": {
|
||||||
|
"error": {
|
||||||
|
"invalid_token": "invalid_token%s",
|
||||||
|
"captcha": "captcha%s%s",
|
||||||
|
"captcha_again": "captcha_again%s%s",
|
||||||
|
"impostor": "impostor%s%s",
|
||||||
|
"broadcaster_should_log_in": "broadcaster_should_log_in",
|
||||||
|
"wrong_username_or_password": "wrong_username_or_password%s",
|
||||||
|
"blacklisted": "Du wurdest ge-blacklist-et.",
|
||||||
|
"not_whitelisted": "Du wurdest nicht ge-whitelist-et.",
|
||||||
|
"offline": "Der Stream ist offline.",
|
||||||
|
"ratelimit": "Du hast den Stream bereits vor kurzem angefragt. Versuche es erneut in %.1f Sekunden.",
|
||||||
|
"limit": "Du hast eine Stream-Verbindung %d mal gleichzeitig angefragt. Beende eine Verbindung bevor du eine neue Anfrage versuchst."
|
||||||
|
},
|
||||||
|
"internal": {
|
||||||
|
"captcha_required": "Captcha benötigt",
|
||||||
|
"captcha_incorrect": "Falsches Captcha",
|
||||||
|
"captcha_expired": "Captcha abgelaufen",
|
||||||
|
"message_ratelimited": "Chat-Überlastung in den letzten %.0f Sekunden",
|
||||||
|
"message_suspected_duplicate": "Verworfen, Duplikat vermutet",
|
||||||
|
"message_empty": "Die Nachricht war leer",
|
||||||
|
"message_practically_empty": "Die Nachricht war praktisch leer",
|
||||||
|
"message_too_long": "Nachricht hat %d Zeichen überschritten",
|
||||||
|
"message_too_many_lines": "Nachricht hat %d Zeilen überschritten",
|
||||||
|
"message_too_many_apparent_lines": "Nachricht würde %d oder mehr Zeilen umfassen",
|
||||||
|
"appearance_changed": "Aussehen geändert",
|
||||||
|
"name_empty": "Namensfeld war leer",
|
||||||
|
"name_too_long": "Name überschreitet %d Zeichen",
|
||||||
|
"colour_invalid_css": "Ungültige CSS-Farbe",
|
||||||
|
"colour_insufficient_contrast": "Farbe hat nicht ausreichend Kontrast: %s",
|
||||||
|
"password_too_long": "Passwort überschreitet %d Zeichen"
|
||||||
|
},
|
||||||
|
"captcha": {
|
||||||
|
"captcha_failed_to_load": "Captcha konnte nicht geladen werden",
|
||||||
|
"click_for_a_new_captcha": "Klick für ein neues Captcha"
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"info": "Info",
|
||||||
|
"chat": "Chat",
|
||||||
|
"both": "Beide",
|
||||||
|
"users": "Benutzer",
|
||||||
|
"stream_chat": "Stream-Chat",
|
||||||
|
"users_in_chat": "Benutzer im Chat",
|
||||||
|
"source": "Quelltext"
|
||||||
|
},
|
||||||
|
"stream": {
|
||||||
|
"offline": "[offline]"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"viewers": "%d Zuschauer",
|
||||||
|
"uptime": "Zeit:",
|
||||||
|
"reload_stream": "Stream neu laden"
|
||||||
|
},
|
||||||
|
"chat": {
|
||||||
|
"users": "Benutzer",
|
||||||
|
"click_to_refresh": "Klicken zum aktualisieren",
|
||||||
|
"hide_timeout_notice": "Auszeitnachricht ausblenden",
|
||||||
|
"watching": "Zuschauer (%d)",
|
||||||
|
"not_watching": "Inaktive Zuschauer (%d)",
|
||||||
|
"you": " (Du)",
|
||||||
|
"timed_out": "Zeitüberschreitung"
|
||||||
|
},
|
||||||
|
"form": {
|
||||||
|
"click_to_dismiss": "Klicken zum Ausblenden",
|
||||||
|
"send_a_message": "Schreib eine Nachricht...",
|
||||||
|
"captcha": "Captcha",
|
||||||
|
"settings": "Einstellungen",
|
||||||
|
"captcha_failed_to_load": "Captcha konnte nicht geladen werden",
|
||||||
|
"click_for_a_new_captcha": "Klick für ein neues Captcha",
|
||||||
|
"chat": "Chat",
|
||||||
|
"name": "Name:",
|
||||||
|
"tripcode": "Tripcode:",
|
||||||
|
"no_tripcode": "(kein Tripcode)",
|
||||||
|
"set": "setzen",
|
||||||
|
"cleared": "(geleert)",
|
||||||
|
"undo": "zurück",
|
||||||
|
"tripcode_password": "(Tripcode-Passwort)",
|
||||||
|
"return_to_chat": "Zurück zum Chat",
|
||||||
|
"update": "Aktualisieren"
|
||||||
|
},
|
||||||
|
"js": {
|
||||||
|
"offline": "[offline]",
|
||||||
|
"reload_stream": "Stream neuladen",
|
||||||
|
"chat_scroll_paused": "Chat-Rollen pausiert. Klick zum Wiederaufnehmen.",
|
||||||
|
"not_connected": "Nicht mit dem Chat verbunden",
|
||||||
|
"broadcaster": "Sender",
|
||||||
|
"loading": "Läd...",
|
||||||
|
"click_for_a_new_captcha": "Klick für ein neues Captcha",
|
||||||
|
"viewers": "{0} Zuschauer",
|
||||||
|
"you": " (Du)",
|
||||||
|
"watching": "Zuschauer ({0})",
|
||||||
|
"not_watching": "Inaktive Zuschauer ({0})",
|
||||||
|
"errors": "Fehler:",
|
||||||
|
"connecting_to_chat": "Baue Verbindung zum Chat auf...",
|
||||||
|
"connected_to_chat": "Verbunden mit dem Chat",
|
||||||
|
"disconnected_from_chat": "Verbindung zum Chat getrennt",
|
||||||
|
"error_connecting_to_chat": "Fehler bei der Verbindung zum Chat",
|
||||||
|
"error_connecting_to_chat_terse": "Fehler"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"400": null,
|
||||||
|
"401": null,
|
||||||
|
"403": null,
|
||||||
|
"404": null,
|
||||||
|
"405": null,
|
||||||
|
"410": null,
|
||||||
|
"500": null
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
{
|
||||||
|
"anonstream": {
|
||||||
|
"error": {
|
||||||
|
"invalid_token": "Your token contains disallowed characters or is too long. Tokens must match this regular expression: %s",
|
||||||
|
"captcha": "You have not solved the access captcha. %sClick here.%s",
|
||||||
|
"captcha_again": "You must solve the access captcha again because you have been away. %sClick here.%s",
|
||||||
|
"impostor": "You are using the broadcaster's token but you are not logged in. The broadcaster should %sclick here%s and log in with the credentials printed in their terminal when they started anonstream.",
|
||||||
|
"broadcaster_should_log_in": "The broadcaster should log in with the credentials printed in their terminal.",
|
||||||
|
"wrong_username_or_password": "Wrong username or password. Refresh the page to try again. %sThe broadcaster should log in with the credentials printed in their terminal.",
|
||||||
|
"blacklisted": "You have been blacklisted.",
|
||||||
|
"not_whitelisted": "You have not been whitelisted.",
|
||||||
|
"offline": "The stream is offline.",
|
||||||
|
"ratelimit": "You have requested the stream recently. Try again in %.1f seconds.",
|
||||||
|
"limit": "You have made %d concurrent requests for the stream. End one of those before making a new request."
|
||||||
|
},
|
||||||
|
"internal": {
|
||||||
|
"captcha_required": "Captcha required",
|
||||||
|
"captcha_incorrect": "Captcha incorrect",
|
||||||
|
"captcha_expired": "Captcha expired",
|
||||||
|
"message_ratelimited": "Chat overuse in the last %.0f seconds",
|
||||||
|
"message_suspected_duplicate": "Discarded suspected duplicate message",
|
||||||
|
"message_empty": "Message was empty",
|
||||||
|
"message_practically_empty": "Message was practically empty",
|
||||||
|
"message_too_long": "Message exceeded %d chars",
|
||||||
|
"message_too_many_lines": "Message exceeded %d lines",
|
||||||
|
"message_too_many_apparent_lines": "Message would span %d or more lines",
|
||||||
|
"appearance_changed": "Changed appearance",
|
||||||
|
"name_empty": "Name was empty",
|
||||||
|
"name_too_long": "Name exceeded %d chars",
|
||||||
|
"colour_invalid_css": "Invalid CSS color",
|
||||||
|
"colour_insufficient_contrast": "Colour had insufficient contrast: %s",
|
||||||
|
"password_too_long": "Password exceeded %d chars"
|
||||||
|
},
|
||||||
|
"captcha": {
|
||||||
|
"captcha_failed_to_load": "Captcha failed to load",
|
||||||
|
"click_for_a_new_captcha": "Click for a new captcha"
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"info": "info",
|
||||||
|
"chat": "chat",
|
||||||
|
"both": "both",
|
||||||
|
"users": "Users",
|
||||||
|
"stream_chat": "Stream chat",
|
||||||
|
"users_in_chat": "Users in chat",
|
||||||
|
"source": "source"
|
||||||
|
},
|
||||||
|
"stream": {
|
||||||
|
"offline": "[offline]"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"viewers": "%d viewers",
|
||||||
|
"uptime": "Uptime:",
|
||||||
|
"reload_stream": "Reload stream"
|
||||||
|
},
|
||||||
|
"chat": {
|
||||||
|
"users": "Users",
|
||||||
|
"click_to_refresh": "Click to refresh",
|
||||||
|
"hide_timeout_notice": "Hide timeout notice",
|
||||||
|
"watching": "Watching (%d)",
|
||||||
|
"not_watching": "Not watching (%d)",
|
||||||
|
"you": " (You)",
|
||||||
|
"timed_out": "Timed out"
|
||||||
|
},
|
||||||
|
"form": {
|
||||||
|
"click_to_dismiss": "Click to dismiss",
|
||||||
|
"send_a_message": "Send a message...",
|
||||||
|
"captcha": "Captcha",
|
||||||
|
"settings": "Settings",
|
||||||
|
"captcha_failed_to_load": "Captcha failed to load",
|
||||||
|
"click_for_a_new_captcha": "Click for a new captcha",
|
||||||
|
"chat": "Chat",
|
||||||
|
"name": "Name:",
|
||||||
|
"tripcode": "Tripcode:",
|
||||||
|
"no_tripcode": "(no tripcode)",
|
||||||
|
"set": "set",
|
||||||
|
"cleared": "(cleared)",
|
||||||
|
"undo": "undo",
|
||||||
|
"tripcode_password": "(tripcode password)",
|
||||||
|
"return_to_chat": "Return to chat",
|
||||||
|
"update": "Update"
|
||||||
|
},
|
||||||
|
"js": {
|
||||||
|
"offline": "[offline]",
|
||||||
|
"reload_stream": "Reload stream",
|
||||||
|
"chat_scroll_paused": "Chat scroll paused. Click to resume.",
|
||||||
|
"not_connected": "Not connected to chat",
|
||||||
|
"broadcaster": "Broadcaster",
|
||||||
|
"loading": "Loading...",
|
||||||
|
"click_for_a_new_captcha": "Click for a new captcha",
|
||||||
|
"viewers": "{0} viewers",
|
||||||
|
"you": " (You)",
|
||||||
|
"watching": "Watching ({0})",
|
||||||
|
"not_watching": "Not watching ({0})",
|
||||||
|
"errors": "Errors:",
|
||||||
|
"connecting_to_chat": "Connecting to chat...",
|
||||||
|
"connected_to_chat": "Connected to chat",
|
||||||
|
"disconnected_from_chat": "Disconnected from chat",
|
||||||
|
"error_connecting_to_chat": "Error connecting to chat",
|
||||||
|
"error_connecting_to_chat_terse": "Error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"400": "Bad Request",
|
||||||
|
"401": "Unauthorized",
|
||||||
|
"403": "Forbidden",
|
||||||
|
"404": "Not Found",
|
||||||
|
"405": "Method Not Allowed",
|
||||||
|
"410": "Gone",
|
||||||
|
"500": "Internal Server Error"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"anonstream": {
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"400": "Плохой запрос",
|
||||||
|
"401": "Неавторизованно",
|
||||||
|
"403": "Запрещено",
|
||||||
|
"404": "Не найден",
|
||||||
|
"405": "Метод не разрешён",
|
||||||
|
"410": null,
|
||||||
|
"500": "Внутренняя ошибка сервера"
|
||||||
|
}
|
||||||
|
}
|
読み込み中…
新しいイシューから参照