forked from andyburke/autonomous.contact
fix: ensure we are loading events properly during fsdb scan
fix: various styling issues on smaller screens fix: map z-index
This commit is contained in:
parent
873773bc91
commit
2d12104875
10 changed files with 126 additions and 38 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import lurid from '@andyburke/lurid';
|
import lurid from '@andyburke/lurid';
|
||||||
import { get_session, get_user, PRECHECK_TABLE, require_user, user_has_write_permission_for_event } from '../../../utils/prechecks.ts';
|
import { get_session, get_user, PRECHECK_TABLE, require_user, user_has_create_permission_for_event } from '../../../utils/prechecks.ts';
|
||||||
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
||||||
import { EVENT, EVENTS, VALIDATE_EVENT } from '../../../models/event.ts';
|
import { EVENT, EVENTS, VALIDATE_EVENT } from '../../../models/event.ts';
|
||||||
import parse_body from '../../../utils/bodyparser.ts';
|
import parse_body from '../../../utils/bodyparser.ts';
|
||||||
|
|
@ -39,7 +39,14 @@ export async function GET(request: Request, meta: Record<string, any>): Promise<
|
||||||
const {
|
const {
|
||||||
event_type,
|
event_type,
|
||||||
event_id
|
event_id
|
||||||
} = /^.*\/events\/(?<event_type>.*?)\/.*\/(?<event_id>[A-Za-z-]+)\.json$/.exec(entry.path)?.groups ?? {};
|
} = /^.*\/events\/.*\/(?<event_type>.*?)\:(?<event_id>[A-Za-z-]+)\.json$/.exec(entry.path)?.groups ?? {};
|
||||||
|
|
||||||
|
console.dir({
|
||||||
|
entry,
|
||||||
|
event_type,
|
||||||
|
event_id,
|
||||||
|
query: meta.query
|
||||||
|
});
|
||||||
|
|
||||||
if (meta.query.after_id && event_id <= meta.query.after_id) {
|
if (meta.query.after_id && event_id <= meta.query.after_id) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -210,7 +217,7 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user_has_write_permission_for_event(meta.user, event)) {
|
if (!user_has_create_permission_for_event(meta.user, event)) {
|
||||||
return CANNED_RESPONSES.permission_denied();
|
return CANNED_RESPONSES.permission_denied();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
:root {
|
:root {
|
||||||
--bg: hsl(from var(--base-color) h 20% 95%);
|
--bg: hsl(from var(--base-color) h 20% 93%);
|
||||||
|
--bg-darker: hsl(from var(--base-color) h 20% 88%);
|
||||||
|
--bg-lighter: hsl(from var(--base-color) h 20% 98%);
|
||||||
|
|
||||||
--text: hsl(from var(--base-color) h 5% 5%);
|
--text: hsl(from var(--base-color) h 5% 5%);
|
||||||
--accent: hsl(from var(--base-color) h calc(s + 10) calc(l + 20));
|
--accent: hsl(from var(--base-color) h calc(s + 10) calc(l + 20));
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ const APP = {
|
||||||
on: function( event_name, callback ) {
|
on: function( event_name, callback ) {
|
||||||
this._event_callbacks[ event_name ] = this._event_callbacks[ event_name ] ?? new Set();
|
this._event_callbacks[ event_name ] = this._event_callbacks[ event_name ] ?? new Set();
|
||||||
this._event_callbacks[event_name ].add( callback );
|
this._event_callbacks[event_name ].add( callback );
|
||||||
|
|
||||||
|
if ( event_name === 'load' && this._loaded ) {
|
||||||
|
setTimeout( callback, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -90,6 +95,7 @@ const APP = {
|
||||||
},
|
},
|
||||||
|
|
||||||
load: async function() {
|
load: async function() {
|
||||||
|
this._loaded = false;
|
||||||
this.server = {
|
this.server = {
|
||||||
name: document.title,
|
name: document.title,
|
||||||
url: window.location.origin ?? window.location.href,
|
url: window.location.origin ?? window.location.href,
|
||||||
|
|
@ -126,6 +132,7 @@ const APP = {
|
||||||
this.check_if_logged_in();
|
this.check_if_logged_in();
|
||||||
this.extract_url_hash_info();
|
this.extract_url_hash_info();
|
||||||
this._emit( 'load', this );
|
this._emit( 'load', this );
|
||||||
|
this._loaded = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
update_user: async function( user ) {
|
update_user: async function( user ) {
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,40 @@
|
||||||
|
|
||||||
#auth-container {
|
#auth-container {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
|
max-height: calc(min(90vh,900px));
|
||||||
|
border-radius: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: hsl(from var(--bg) h s calc(l/1.1) / 0.5);
|
background: var(--bg-lighter);
|
||||||
max-width: 40em;
|
max-width: 40em;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
border-radius: calc( var(--border-radius) * 2);
|
border-radius: calc( var(--border-radius) * 2.5);
|
||||||
|
padding: 2em 1em;
|
||||||
|
overflow-y: scroll;
|
||||||
|
|
||||||
transition: all 0.33s ease;
|
transition: all 0.33s ease;
|
||||||
animation: zoomsettle 0.4s ease;
|
animation: zoomsettle 0.4s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#signup-tab,
|
||||||
|
#login-tab {
|
||||||
|
padding: 0.5em;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 480px) {
|
||||||
|
#auth-container {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-container h1 {
|
||||||
|
font-size: x-large;
|
||||||
|
}
|
||||||
|
|
||||||
|
#auth-container h3 {
|
||||||
|
font-size: medium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes zoomsettle {
|
@keyframes zoomsettle {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|
|
||||||
|
|
@ -73,18 +73,18 @@
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-tock.time-tock:has(+ .user-tock.time-tick),
|
#chat-container .user-tock.time-tock:has(+ .user-tock.time-tick),
|
||||||
.user-tock.time-tick:has(+ .user-tock.time-tock),
|
#chat-container .user-tock.time-tick:has(+ .user-tock.time-tock),
|
||||||
.user-tick.time-tock:has(+ .user-tick.time-tick),
|
#chat-container .user-tick.time-tock:has(+ .user-tick.time-tick),
|
||||||
.user-tick.time-tick:has(+ .user-tick.time-tock),
|
#chat-container .user-tick.time-tick:has(+ .user-tick.time-tock),
|
||||||
.user-tock.time-tock:has(+ .user-tick.time-tick),
|
#chat-container .user-tock.time-tock:has(+ .user-tick.time-tick),
|
||||||
.user-tock.time-tick:has(+ .user-tick.time-tock),
|
#chat-container .user-tock.time-tick:has(+ .user-tick.time-tock),
|
||||||
.user-tick.time-tock:has(+ .user-tock.time-tick),
|
#chat-container .user-tick.time-tock:has(+ .user-tock.time-tick),
|
||||||
.user-tick.time-tick:has(+ .user-tock.time-tock),
|
#chat-container .user-tick.time-tick:has(+ .user-tock.time-tock),
|
||||||
.user-tock.time-tock:last-of-type,
|
#chat-container .user-tock.time-tock:last-of-type,
|
||||||
.user-tock.time-tick:last-of-type,
|
#chat-container .user-tock.time-tick:last-of-type,
|
||||||
.user-tick.time-tock:last-of-type,
|
#chat-container .user-tick.time-tock:last-of-type,
|
||||||
.user-tick.time-tick:last-of-type {
|
#chat-container .user-tick.time-tick:last-of-type {
|
||||||
/* border: 1px dotted red; */
|
/* border: 1px dotted red; */
|
||||||
margin-bottom: 1rem !important;
|
margin-bottom: 1rem !important;
|
||||||
padding-bottom: 0.25rem !important;
|
padding-bottom: 0.25rem !important;
|
||||||
|
|
@ -92,31 +92,31 @@
|
||||||
margin-top: 0.5rem !important;
|
margin-top: 0.5rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-tock.time-tock:has(+ .user-tock.time-tock),
|
#chat-container .user-tock.time-tock:has(+ .user-tock.time-tock),
|
||||||
.user-tock.time-tick:has(+ .user-tock.time-tick),
|
#chat-container .user-tock.time-tick:has(+ .user-tock.time-tick),
|
||||||
.user-tick.time-tock:has(+ .user-tick.time-tock),
|
#chat-container .user-tick.time-tock:has(+ .user-tick.time-tock),
|
||||||
.user-tick.time-tick:has(+ .user-tick.time-tick) {
|
#chat-container .user-tick.time-tick:has(+ .user-tick.time-tick) {
|
||||||
/* border: 1px dotted blue; */
|
/* border: 1px dotted blue; */
|
||||||
margin-bottom: -0.75rem !important;
|
margin-bottom: -0.75rem !important;
|
||||||
padding-top: 0 !important;
|
padding-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-tock.time-tock+.user-tock.time-tick:has(+ .user-tock.time-tick),
|
#chat-container .user-tock.time-tock+.user-tock.time-tick:has(+ .user-tock.time-tick),
|
||||||
.user-tock.time-tick+.user-tock.time-tock:has(+ .user-tock.time-tock),
|
#chat-container .user-tock.time-tick+.user-tock.time-tock:has(+ .user-tock.time-tock),
|
||||||
.user-tick.time-tock+.user-tick.time-tick:has(+ .user-tick.time-tick),
|
#chat-container .user-tick.time-tock+.user-tick.time-tick:has(+ .user-tick.time-tick),
|
||||||
.user-tick.time-tick+.user-tick.time-tock:has(+ .user-tick.time-tock),
|
#chat-container .user-tick.time-tick+.user-tick.time-tock:has(+ .user-tick.time-tock),
|
||||||
.user-tock.time-tock+.user-tick.time-tick:has(+ .user-tick.time-tick),
|
#chat-container .user-tock.time-tock+.user-tick.time-tick:has(+ .user-tick.time-tick),
|
||||||
.user-tock.time-tick+.user-tick.time-tock:has(+ .user-tick.time-tock),
|
#chat-container .user-tock.time-tick+.user-tick.time-tock:has(+ .user-tick.time-tock),
|
||||||
.user-tick.time-tock+.user-tock.time-tick:has(+ .user-tock.time-tick),
|
#chat-container .user-tick.time-tock+.user-tock.time-tick:has(+ .user-tock.time-tick),
|
||||||
.user-tick.time-tick+.user-tock.time-tock:has(+ .user-tock.time-tock) {
|
#chat-container .user-tick.time-tick+.user-tock.time-tock:has(+ .user-tock.time-tock) {
|
||||||
/* border: 1px dotted green; */
|
/* border: 1px dotted green; */
|
||||||
margin-bottom: -0.75rem !important;
|
margin-bottom: -0.75rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat .message-container.user-tick.time-tick+.message-container.user-tick.time-tick .info-container,
|
#chat-container .message-container.user-tick.time-tick+.message-container.user-tick.time-tick .info-container,
|
||||||
#chat .message-container.user-tick.time-tock+.message-container.user-tick.time-tock .info-container,
|
#chat-container .message-container.user-tick.time-tock+.message-container.user-tick.time-tock .info-container,
|
||||||
#chat .message-container.user-tock.time-tick+.message-container.user-tock.time-tick .info-container,
|
#chat-container .message-container.user-tock.time-tick+.message-container.user-tock.time-tick .info-container,
|
||||||
#chat .message-container.user-tock.time-tock+.message-container.user-tock.time-tock .info-container {
|
#chat-container .message-container.user-tock.time-tock+.message-container.user-tock.time-tock .info-container {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
height: 0;
|
height: 0;
|
||||||
|
|
@ -170,7 +170,7 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#chat .message-container .message-actions-container input[type="checkbox"]:checked~.message-action {
|
#chat-container .message-container .message-actions-container input[type="checkbox"]:checked~.message-action {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
width: 3.25rem;
|
width: 3.25rem;
|
||||||
margin-right: 1.25rem;
|
margin-right: 1.25rem;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
"preview"
|
"preview"
|
||||||
"title"
|
"title"
|
||||||
"info"
|
"info"
|
||||||
|
"reactions"
|
||||||
"content"
|
"content"
|
||||||
"newessay"
|
"newessay"
|
||||||
"replies";
|
"replies";
|
||||||
|
|
@ -71,6 +72,10 @@
|
||||||
font-size: xx-large;
|
font-size: xx-large;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.essay-container .reactions-container {
|
||||||
|
grid-area: reactions;
|
||||||
|
}
|
||||||
|
|
||||||
.essay-container .content-container {
|
.essay-container .content-container {
|
||||||
grid-area: content;
|
grid-area: content;
|
||||||
padding-left: 0.25rem;
|
padding-left: 0.25rem;
|
||||||
|
|
@ -78,6 +83,10 @@
|
||||||
font-size: large;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.essay-container .content-container .html-from-markdown {
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.essay-container button[commandfor="eventactionspopover"] {
|
.essay-container button[commandfor="eventactionspopover"] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0.25rem;
|
bottom: 0.25rem;
|
||||||
|
|
@ -189,11 +198,11 @@
|
||||||
<span class="short">${context.essay_datetime.short}</span>
|
<span class="short">${context.essay_datetime.short}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="reactions-container"></div>
|
||||||
<div class="title-container">${context.essay.data.title}</div>
|
<div class="title-container">${context.essay.data.title}</div>
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
${htmlify(md_to_html(context.essay.data.essay))}
|
${htmlify(md_to_html(context.essay.data.essay))}
|
||||||
</div>
|
</div>
|
||||||
<div class="reactions-container"></div>
|
|
||||||
<button class="icon more" commandfor="eventactionspopover"></button>
|
<button class="icon more" commandfor="eventactionspopover"></button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"expander preview info"
|
"expander preview info"
|
||||||
"expander preview subject"
|
"expander preview subject"
|
||||||
|
". . reactions"
|
||||||
". . content"
|
". . content"
|
||||||
". . newpost"
|
". . newpost"
|
||||||
". . replies";
|
". . replies";
|
||||||
|
|
@ -111,6 +112,10 @@
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-container .reactions-container {
|
||||||
|
grid-area: reactions;
|
||||||
|
}
|
||||||
|
|
||||||
.post-container button[commandfor="eventactionspopover"] {
|
.post-container button[commandfor="eventactionspopover"] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0.25rem;
|
bottom: 0.25rem;
|
||||||
|
|
@ -125,6 +130,35 @@
|
||||||
.post-container .replies-container {
|
.post-container .replies-container {
|
||||||
grid-area: replies;
|
grid-area: replies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 480px) {
|
||||||
|
.post-container {
|
||||||
|
grid-template-rows: 120px auto auto auto 1fr;
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
grid-template-areas:
|
||||||
|
". preview"
|
||||||
|
"expander info"
|
||||||
|
"expander subject"
|
||||||
|
". reactions"
|
||||||
|
". content"
|
||||||
|
". newpost"
|
||||||
|
". replies";
|
||||||
|
|
||||||
|
max-height: 16rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-container .media-preview-container {
|
||||||
|
overflow: hidden;
|
||||||
|
display: grid;
|
||||||
|
align-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-container .media-preview-container img {
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
left: 4em;
|
left: 4em;
|
||||||
right: 4em;
|
right: 4em;
|
||||||
bottom: 4em;
|
bottom: 4em;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 640px) {
|
@media screen and (max-width: 640px) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
APP.on( 'load', () => {
|
APP.on( 'load', () => {
|
||||||
|
console.log( 'loaded' );
|
||||||
const tab_switchers = document.querySelectorAll(".tabswitch");
|
const tab_switchers = document.querySelectorAll(".tabswitch");
|
||||||
for (const tab_switch of tab_switchers) {
|
for (const tab_switch of tab_switchers) {
|
||||||
tab_switch.addEventListener("input", (event) => {
|
tab_switch.addEventListener("input", (event) => {
|
||||||
|
|
@ -15,7 +16,7 @@
|
||||||
const view = tab_selector.dataset.view;
|
const view = tab_selector.dataset.view;
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
window.location.hash = `/${view}${ document.body.dataset.channel ? `/channel/${ document.body.dataset.channel }` : '' }`;
|
window.location.hash = `/${view}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ export function require_user(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function user_has_write_permission_for_event(user: USER, event: EVENT) {
|
export function user_has_create_permission_for_event(user: USER, event: EVENT) {
|
||||||
return user.permissions.includes('events.create.' + event.type) || (Deno.env.get('DENO_ENV') === 'test' && event.type === 'test');
|
return user.permissions.includes('events.create.' + event.type) || (Deno.env.get('DENO_ENV') === 'test' && event.type === 'test');
|
||||||
}
|
}
|
||||||
|
export function user_has_write_permission_for_event(user: USER, event: EVENT) {
|
||||||
|
return user.permissions.includes('events.write.' + event.type) || (Deno.env.get('DENO_ENV') === 'test' && event.type === 'test');
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue