Compare commits
4 Commits
cd3fce17ae
...
b0793b8a86
| Author | SHA1 | Date | |
|---|---|---|---|
|
b0793b8a86
|
|||
|
dc1ff4446e
|
|||
|
06b417f9a1
|
|||
|
594272d298
|
@@ -92,10 +92,10 @@ $ pip install -r requirements.txt
|
||||
4. run dev server:
|
||||
|
||||
```bash
|
||||
$ python -m app.run
|
||||
$ python -m app.run -d
|
||||
```
|
||||
|
||||
the server will run on localhost:8080. when run for the first time, it will create an admin account and print its credentials to the terminal, so make sure to run this in an interactive session.
|
||||
the server will run on localhost:8080 (and will be available on the local network as well; if this is not desired, drop the `-d` flag). when run for the first time, it will create an admin account and print its credentials to the terminal, so make sure to run this in an interactive session.
|
||||
|
||||
press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop the server.
|
||||
|
||||
@@ -110,4 +110,3 @@ when you want to run the server again, make sure to activate the venv first:
|
||||
$ source .venv/bin/activate
|
||||
$ python -m app.run
|
||||
```
|
||||
|
||||
|
||||
@@ -14,9 +14,11 @@ from ..auth import (
|
||||
login_required, revoke_session, get_active_user,
|
||||
parse_display_name, revoke_all_sessions, csrf_verified
|
||||
)
|
||||
from ..models import Users, Posts, Reactions, Threads, Avatars, PostHistory, Mentions
|
||||
from ..models import Users, Posts, Reactions, Threads, Avatars, PostHistory, Mentions, BookmarkCollections
|
||||
from ..constants import PermissionLevel, InfoboxKind
|
||||
from ..util import get_form_checkbox
|
||||
from ..lib.babycode import babycode_to_html
|
||||
from ..db import db
|
||||
import math
|
||||
import os
|
||||
import time
|
||||
@@ -202,6 +204,8 @@ def sign_up_post():
|
||||
'created_at': int(time.time()),
|
||||
})
|
||||
|
||||
BookmarkCollections.create_default(user.id)
|
||||
|
||||
if username_pair[0] != username_pair[1]:
|
||||
user.update({
|
||||
'display_name': parse_display_name(username_pair[1])
|
||||
@@ -386,11 +390,28 @@ def set_personalization(username):
|
||||
session['sort_by'] = request.form.get('sort_by', 'activity')
|
||||
session['dont_subscribe_by_default'] = not get_form_checkbox('subscribe_by_default')
|
||||
|
||||
old_display_name = user.display_name
|
||||
new_display_name = parse_display_name(request.form.get('display_name', ''))
|
||||
|
||||
user.update({
|
||||
'status': request.form.get('status', '')[:100],
|
||||
'display_name': parse_display_name(request.form.get('display_name', ''))
|
||||
'display_name': new_display_name
|
||||
})
|
||||
|
||||
if old_display_name != new_display_name:
|
||||
# re-parse posts with mentions
|
||||
q = """SELECT DISTINCT m.revision_id FROM mentions m
|
||||
JOIN post_history ph ON m.revision_id = ph.id
|
||||
JOIN posts p ON p.current_revision_id = ph.id
|
||||
WHERE m.mentioned_user_id = ?"""
|
||||
mentions = db.query(q, int(user.id))
|
||||
with db.transaction():
|
||||
for mention in mentions:
|
||||
rev = PostHistory.find({'id': int(mention['revision_id'])})
|
||||
parsed_content = babycode_to_html(rev.original_markup).result
|
||||
rev.update({'content': parsed_content})
|
||||
|
||||
|
||||
flash('Personalization settings updated.', InfoboxKind.INFO)
|
||||
return redirect(url_for('.settings', username=username))
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
from app import create_app
|
||||
import os
|
||||
import sys
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1 and sys.argv[1] == '-d':
|
||||
hostname = '0.0.0.0'
|
||||
else:
|
||||
hostname = '127.0.0.1'
|
||||
app.run(
|
||||
host = "127.0.0.1",
|
||||
host = hostname,
|
||||
port = 8080
|
||||
)
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<span class="flex-last js-only" data-r="enhance babycodeEditorCharCount">stub: char count</span>
|
||||
</span>
|
||||
<input type="hidden" name="babycode_banned_tags" id="{{id}}-banned-tags" value="{{banned_tags | unique | list | tojson | forceescape}}">
|
||||
<textarea name="babycode_content" id="{{id}}" class="babycode-editor" placeholder="{{placeholder}}" {{'required' if required else ''}} autocomplete="off" maxlength="5000" data-r="insertBabycode babycodePreviewInit babycodeEditorCharCountInit" data-listeners="input" data-s="babycodeEditorCharCount" data-banned-tags="{{banned_tags | unique | list | tojson | forceescape}}">{{ prefill }}</textarea>
|
||||
<textarea name="babycode_content" id="{{id}}" class="babycode-editor" placeholder="{{placeholder}}" {{'required' if required else ''}} autocomplete="off" maxlength="5000" data-r="insertBabycode babycodePreviewInit babycodeEditorCharCountInit babycodeEditorQuote" data-listeners="input" data-s="babycodeEditorCharCount" data-banned-tags="{{banned_tags | unique | list | tojson | forceescape}}">{{ prefill }}</textarea>
|
||||
{%- if banned_tags -%}
|
||||
<div>
|
||||
<span>Forbidden tags:</span>
|
||||
@@ -186,7 +186,7 @@
|
||||
<a class="linkbutton" href="{{url_for('posts.edit', post_id=post.id, _anchor='babycode-content')}}">Edit</a>
|
||||
{%- endif -%}
|
||||
{%- if can_reply -%}
|
||||
<button data-r="enhance" disabled title="This feature requires JavaScript to be enabled.">Quote</button>
|
||||
<button data-r="enhance" data-s="babycodeEditorQuote" disabled title="This feature requires JavaScript to be enabled." data-quote="{{post.original_markup}}" data-poster-name="{{ post.display_name if post.display_name else post.username }}">Quote</button>
|
||||
{%- endif -%}
|
||||
{%- if can_delete -%}
|
||||
<a class="linkbutton critical" href="{{url_for('posts.delete', post_id=post.id)}}">Delete</a>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<input type="hidden" name="last_post_id" value="{{last_post.id}}">
|
||||
<input type="submit" value="{{'Subscribe' if not get_active_user().is_subscribed(thread.id) else 'Unsubscribe'}}">
|
||||
</form>
|
||||
<button disabled title="This feature requires JavaScript to be enabled.">{{icn_bookmark(24)}}Bookmark…</button>
|
||||
<button data-r="enhance" disabled title="This feature requires JavaScript to be enabled.">{{icn_bookmark(24)}}Bookmark…</button>
|
||||
{%- endif -%}
|
||||
<a href="{{url_for('threads.feed', thread_id=thread.id)}}" class="linkbutton rss">Subscribe via RSS</a>
|
||||
</fieldset>
|
||||
|
||||
@@ -848,7 +848,7 @@ a.mention {
|
||||
padding: var(--base-padding);
|
||||
background-color: var(--mention-color);
|
||||
color: black;
|
||||
border: 1px dashed;
|
||||
border: 1px solid hsl(from var(--mention-color) h s 55%);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--hover-color);
|
||||
|
||||
@@ -162,3 +162,11 @@ export function showBabycodePreview(payload, _, el) {
|
||||
el.innerHTML = payload.html;
|
||||
}
|
||||
}
|
||||
|
||||
export function babycodeEditorQuote(ev, sender, el) {
|
||||
console.log(sender.dataset.quote);
|
||||
const newline = el.value.length === 0 ? '' : '\n'
|
||||
el.value += `${newline}[quote=${sender.dataset.posterName}]\n${sender.dataset.quote}\n[/quote]\n\n`
|
||||
b.send({ sender: el }, 'babycodeEditorCharCount');
|
||||
el.focus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user