Add username hints while typing mentions in compose box

This commit is contained in:
Jason McBrayer 2019-01-17 21:02:23 -05:00
parent 10019b34b0
commit 8615c8f801
9 changed files with 66 additions and 6 deletions

View File

@ -223,3 +223,8 @@ input#id_poll_frequency
max-width: 256px; max-width: 256px;
} }
#username_autocomplete
{
height: 0;
}

View File

@ -207,3 +207,8 @@ body.has-navbar-fixed-top, html.has-navbar-fixed-top {
max-width: 256px; max-width: 256px;
} }
#username_autocomplete
{
height: 0;
}

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,12 @@
href="{% static 'css/bulma.min.css' %}"> href="{% static 'css/bulma.min.css' %}">
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/fork-awesome.min.css' %}"> href="{% static 'css/fork-awesome.min.css' %}">
<link rel="stylesheet"
href="{% static 'css/bulma-badge.min.css' %}">
<link rel="stylesheet"
href="{% static 'css/bulma-tooltip.min.css' %}">
<link rel="stylesheet"
href="{% static 'css/magnific-popup.css' %}">
<link rel="stylesheet" href="{% static "css/brutaldon.css" %}"> <link rel="stylesheet" href="{% static "css/brutaldon.css" %}">
{% else %} {% else %}
<link rel="stylesheet" <link rel="stylesheet"
@ -31,7 +37,7 @@
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/bulma-badge.min.css' %}"> href="{% static 'css/bulma-badge.min.css' %}">
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/bulma-badge.min.css' %}"> href="{% static 'css/bulma-tooltip.min.css' %}">
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'css/magnific-popup.css' %}"> href="{% static 'css/magnific-popup.css' %}">
{% endif %} {% endif %}

View File

@ -0,0 +1,8 @@
<div id="username_autocomplete">
{% if not preferences.theme.is_brutalist %}
<div class="tooltip is-tooltip-active is-tooltip-multiline is-tooltip-bottom"
data-tooltip="{{ users }}"></div>
{% else %}
{% endif %}
</div>

View File

@ -17,9 +17,16 @@
<div class="field" > <div class="field" >
<label class="label" >{{ form.status.label }}</label> <label class="label" >{{ form.status.label }}</label>
<div class="control"> <div class="control">
{% render_field form.status class+="textarea is-primary mousetrap" rows="3" %} <textarea name="status" cols="40" rows="3" class="textarea is-primary mousetrap"
required="" id="id_status"
ic-post-to="{% url "user_search" %}"
ic-trigger-on="keyup changed" ic-trigger-delay="500ms"
ic-target="#username_autocomplete">
</textarea>
<div id="username_autocomplete"></div>
</div> </div>
<div id="status_count"></div> <div id="status_count"></div>
</div> </div>
<div class="field has-addons"> <div class="field has-addons">

View File

@ -39,6 +39,7 @@ urlpatterns = [
path('note/next<int:next>', views.note, name='note_next'), path('note/next<int:next>', views.note, name='note_next'),
path('note/prev/<int:prev>', views.note, name='note_prev'), path('note/prev/<int:prev>', views.note, name='note_prev'),
path('notes_count', views.notes_count, name='notes_count'), path('notes_count', views.notes_count, name='notes_count'),
path('user_search', views.user_search, name='user_search'),
path('settings', views.settings, name='settings'), path('settings', views.settings, name='settings'),
path('thread/<int:id>', views.thread, name='thread'), path('thread/<int:id>', views.thread, name='thread'),
path('tags/<tag>', views.tag, name='tag'), path('tags/<tag>', views.tag, name='tag'),

View File

@ -99,6 +99,26 @@ def notes_count(request):
{'notifications': count, {'notifications': count,
'preferences': account.preferences }) 'preferences': account.preferences })
def user_search(request):
check = request.POST.get("status", "").split()
if len(check):
check = check[-1]
if len(check) > 1 and check.startswith('@'):
check = check[1:]
return user_search_inner(request, check)
else:
check = "&nbsp;"
else:
check = "&nbsp;"
return HttpResponse(check)
def user_search_inner(request, query):
account, mastodon = get_usercontext(request)
results = mastodon.search(query)
return render(request, 'intercooler/users.html',
{'users': "\n".join([ user.acct for user in results.accounts ]),
'preferences': account.preferences })
def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_id=None): def timeline(request, timeline='home', timeline_name='Home', max_id=None, since_id=None):
account, mastodon = get_usercontext(request) account, mastodon = get_usercontext(request)
data = mastodon.timeline(timeline, limit=100, max_id=max_id, since_id=since_id) data = mastodon.timeline(timeline, limit=100, max_id=max_id, since_id=since_id)

View File

@ -5,26 +5,32 @@
bulma-extensions@^2.2.2: bulma-extensions@^2.2.2:
version "2.2.2" version "2.2.2"
resolved "https://registry.yarnpkg.com/bulma-extensions/-/bulma-extensions-2.2.2.tgz#d46f11d1242a3fdc60a983afaea0b5e6c137362d" resolved "https://registry.yarnpkg.com/bulma-extensions/-/bulma-extensions-2.2.2.tgz#d46f11d1242a3fdc60a983afaea0b5e6c137362d"
integrity sha512-6hV6SiRT7RZD5+scn/462Dz8RURRgxuvlCy+R5LH9U6FLn7Q/sInAA5VdK8c4DKpxZjfsipp72EAKM7yzgzRig==
bulma@^0.7.1: bulma@^0.7.1:
version "0.7.1" version "0.7.2"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.7.1.tgz#73c2e3b2930c90cc272029cbd19918b493fca486" resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.7.2.tgz#8e944377b74c7926558830d38d8e19eaf49f5fb6"
integrity sha512-6JHEu8U/1xsyOst/El5ImLcZIiE2JFXgvrz8GGWbnDLwTNRPJzdAM0aoUM1Ns0avALcVb6KZz9NhzmU53dGDcQ==
bulmaswatch@^0.6.2: bulmaswatch@^0.6.2:
version "0.6.2" version "0.6.2"
resolved "https://registry.yarnpkg.com/bulmaswatch/-/bulmaswatch-0.6.2.tgz#5d102b1986d5f48d7f45ff68354c5fe367dc1c76" resolved "https://registry.yarnpkg.com/bulmaswatch/-/bulmaswatch-0.6.2.tgz#5d102b1986d5f48d7f45ff68354c5fe367dc1c76"
integrity sha512-IMYjMqEnHQ1Yhtzkia3ojeFRvJr8DnLBiDMUuvLcGtJwyaAuZ8AQ4tT3TK21lcnt7cngeM3CKzBtkbQulWQI9w==
fork-awesome@^1.1.0: fork-awesome@^1.1.0:
version "1.1.0" version "1.1.5"
resolved "https://registry.yarnpkg.com/fork-awesome/-/fork-awesome-1.1.0.tgz#771c8fcee6bb3d1481c8394094d4ea1f2d3e4acc" resolved "https://registry.yarnpkg.com/fork-awesome/-/fork-awesome-1.1.5.tgz#09370221ad752a5396beb62bcb7bd11dab09a132"
integrity sha512-AcyPBje/cBkNjLAqxs301XjWSTLcXyktXjo0zhyrXDiEbTFi48HqBYbcPL0QBdtRHXrEdj+1rR5KublMQDwPwQ==
intercooler@^1.2.1: intercooler@^1.2.1:
version "1.2.1" version "1.2.1"
resolved "https://registry.yarnpkg.com/intercooler/-/intercooler-1.2.1.tgz#50e9727ef2643ef7d5130c8e58f2af78098aa01f" resolved "https://registry.yarnpkg.com/intercooler/-/intercooler-1.2.1.tgz#50e9727ef2643ef7d5130c8e58f2af78098aa01f"
integrity sha512-2/UV4RTZltP8tlV16fqu94aum4zO3uTbDcv843qjGInd+Lf2Pfm2gs2gIlCx5fYo6yUSz9cEwqc3r/+SddugMg==
jquery@^3.3.1: jquery@^3.3.1:
version "3.3.1" version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
integrity sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==
magnific-popup@^1.1.0: magnific-popup@^1.1.0:
version "1.1.0" version "1.1.0"
@ -34,3 +40,4 @@ magnific-popup@^1.1.0:
mousetrap@^1.6.2: mousetrap@^1.6.2:
version "1.6.2" version "1.6.2"
resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587" resolved "https://registry.yarnpkg.com/mousetrap/-/mousetrap-1.6.2.tgz#caadd9cf886db0986fb2fee59a82f6bd37527587"
integrity sha512-jDjhi7wlHwdO6q6DS7YRmSHcuI+RVxadBkLt3KHrhd3C2b+w5pKefg3oj5beTcHZyVFA9Aksf+yEE1y5jxUjVA==