Start work on formatter for content
This commit is contained in:
Melody Becker 2024-10-23 17:02:19 +02:00
parent 1dbdec1905
commit c7af216ce3
30 changed files with 292 additions and 22 deletions

View file

@ -3,6 +3,7 @@
<Note::UserHeader <Note::UserHeader
@displayname="{{@note.displayname}}" @displayname="{{@note.displayname}}"
@handle="@{{@note.username}}@{{@note.server}}" @handle="@{{@note.username}}@{{@note.server}}"
@server="{{@note.servertype}}"
/> />
<Note::Content @content="{{@note.content}}" /> <Note::Content @content="{{@note.content}}" />
<div class="note-timestamps-container"> <div class="note-timestamps-container">

View file

@ -0,0 +1,15 @@
<div class="{{ @classes }}">
{{#if (equals @server "mastodon")}}
<Note::Formatter::Mastodon>{{ @content }}Masto</Note::Formatter::Mastodon>
{{else if (equals @server "misskey")}}
<Note::Formatter::Misskey>{{ @content }}Misskey</Note::Formatter::Misskey>
{{else if (equals @server "akoma")}}
<Note::Formatter::Akoma>{{ @content }}Akoma</Note::Formatter::Akoma>
{{else if (equals @server "linstrom")}}
<Note::Formatter::Linstrom>{{ @content }}Linstrom</Note::Formatter::Linstrom>
{{else if (equals @server "wafrn")}}
<Note::Formatter::Wafrn>{{ @content }}Wafrn</Note::Formatter::Wafrn>
{{else}}
<Note::Formatter::Linstrom>{{ @content }}Unkown:{{@server}}</Note::Formatter::Linstrom>
{{/if}}
</div>

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface NoteFormatterAkomaSignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class NoteFormatterAkoma extends Component<NoteFormatterAkomaSignature> {}

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface NoteFormatterLinstromSignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class NoteFormatterLinstrom extends Component<NoteFormatterLinstromSignature> {}

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface NoteFormatterMastodonSignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class NoteFormatterMastodon extends Component<NoteFormatterMastodonSignature> {}

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface NoteFormatterMisskeySignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class NoteFormatterMisskey extends Component<NoteFormatterMisskeySignature> {}

View file

@ -0,0 +1 @@
{{yield}}

View file

@ -0,0 +1,14 @@
import Component from '@glimmer/component';
export interface NoteFormatterWafrnSignature {
// The arguments accepted by the component
Args: {};
// Any blocks yielded by the component
Blocks: {
default: [];
};
// The element to which `...attributes` is applied in the component template
Element: null;
}
export default class NoteFormatterWafrn extends Component<NoteFormatterWafrnSignature> {}

View file

@ -3,7 +3,8 @@
<p>Pfp</p> <p>Pfp</p>
</div> </div>
<div class="note-user-name-and-handle"> <div class="note-user-name-and-handle">
<p class="note-user-displayname">{{@displayname}}</p> <Note::Formatter @classes="note-user-displayname" @content={{@displayname}} @server={{@server}}/>
<p class="note-user-displayname"></p>
<p class="note-user-handle">{{@handle}}</p> <p class="note-user-handle">{{@handle}}</p>
</div> </div>
</div> </div>

View file

@ -1,5 +1,6 @@
<div class="timeline"> <div class="timeline">
{{#each @notes as |note|}} {{#each @notes as |note|}}
<Note @isInTimeline="true" @note={{note}}/> <Note @isInTimeline="true" @note={{note}}/>
<hr class="timeline-separator">
{{/each}} {{/each}}
</div> </div>

View file

@ -0,0 +1,6 @@
import { helper } from '@ember/component/helper';
export default helper(function equals(args) {
if (args.length != 2) return false;
return args[0] == args[1];
});

View file

@ -19,6 +19,7 @@ export default class ApplicationRoute extends Route {
content: 'lorem ipsum', content: 'lorem ipsum',
createdAt: Date.now() - 360000, createdAt: Date.now() - 360000,
editedAt: Date.now() - 60000, editedAt: Date.now() - 60000,
servertype: 'mastodon',
}, },
{ {
displayname: 'Melody', displayname: 'Melody',
@ -27,6 +28,7 @@ export default class ApplicationRoute extends Route {
content: content:
'Grapple keel reef fathom haul wind bilge rat swing the lead belay line pink. Man-of-war mizzenmast killick lookout yo-ho-ho Sail ho gabion careen sutler stern. Draught wherry lookout schooner prow hail-shot spanker Letter of Marque lateen sail strike colors.\n\nLad heave to topgallant scallywag scuppers Spanish Main poop deck spike hulk broadside. Snow take a caulk hornswaggle gaff swab quarter lugger spanker bilge provost. Man-of-war measured fer yer chains lugger cable loaded to the gunwalls prow piracy snow doubloon furl.\n\nDead men tell no tales jib chase guns gunwalls Gold Road smartly nipperkin topsail bilge water Pirate Round. Gaff gunwalls bilged on her anchor bilge water scourge of the seven seas parley ho sheet chase guns squiffy. Scuppers fathom ho quarter gally heave to yardarm coxswain red ensign pink.', 'Grapple keel reef fathom haul wind bilge rat swing the lead belay line pink. Man-of-war mizzenmast killick lookout yo-ho-ho Sail ho gabion careen sutler stern. Draught wherry lookout schooner prow hail-shot spanker Letter of Marque lateen sail strike colors.\n\nLad heave to topgallant scallywag scuppers Spanish Main poop deck spike hulk broadside. Snow take a caulk hornswaggle gaff swab quarter lugger spanker bilge provost. Man-of-war measured fer yer chains lugger cable loaded to the gunwalls prow piracy snow doubloon furl.\n\nDead men tell no tales jib chase guns gunwalls Gold Road smartly nipperkin topsail bilge water Pirate Round. Gaff gunwalls bilged on her anchor bilge water scourge of the seven seas parley ho sheet chase guns squiffy. Scuppers fathom ho quarter gally heave to yardarm coxswain red ensign pink.',
createdAt: Date.now() - 3600, createdAt: Date.now() - 3600,
servertype: 'linstrom',
}, },
{ {
displayname: 'alice', displayname: 'alice',
@ -35,6 +37,7 @@ export default class ApplicationRoute extends Route {
content: 'lorem ipsum', content: 'lorem ipsum',
createdAt: Date.now() - 360000, createdAt: Date.now() - 360000,
editedAt: Date.now() - 60000, editedAt: Date.now() - 60000,
servertype: 'wafrn',
}, },
{ {
displayname: 'Melody', displayname: 'Melody',
@ -43,6 +46,7 @@ export default class ApplicationRoute extends Route {
content: content:
'Grapple keel reef fathom haul wind bilge rat swing the lead belay line pink. Man-of-war mizzenmast killick lookout yo-ho-ho Sail ho gabion careen sutler stern. Draught wherry lookout schooner prow hail-shot spanker Letter of Marque lateen sail strike colors.\n\nLad heave to topgallant scallywag scuppers Spanish Main poop deck spike hulk broadside. Snow take a caulk hornswaggle gaff swab quarter lugger spanker bilge provost. Man-of-war measured fer yer chains lugger cable loaded to the gunwalls prow piracy snow doubloon furl.\n\nDead men tell no tales jib chase guns gunwalls Gold Road smartly nipperkin topsail bilge water Pirate Round. Gaff gunwalls bilged on her anchor bilge water scourge of the seven seas parley ho sheet chase guns squiffy. Scuppers fathom ho quarter gally heave to yardarm coxswain red ensign pink.', 'Grapple keel reef fathom haul wind bilge rat swing the lead belay line pink. Man-of-war mizzenmast killick lookout yo-ho-ho Sail ho gabion careen sutler stern. Draught wherry lookout schooner prow hail-shot spanker Letter of Marque lateen sail strike colors.\n\nLad heave to topgallant scallywag scuppers Spanish Main poop deck spike hulk broadside. Snow take a caulk hornswaggle gaff swab quarter lugger spanker bilge provost. Man-of-war measured fer yer chains lugger cable loaded to the gunwalls prow piracy snow doubloon furl.\n\nDead men tell no tales jib chase guns gunwalls Gold Road smartly nipperkin topsail bilge water Pirate Round. Gaff gunwalls bilged on her anchor bilge water scourge of the seven seas parley ho sheet chase guns squiffy. Scuppers fathom ho quarter gally heave to yardarm coxswain red ensign pink.',
createdAt: Date.now() - 3600, createdAt: Date.now() - 3600,
servertype: 'unknown',
}, },
], ],
}; };

View file

@ -1,13 +0,0 @@
import Service from '@ember/service'
export default class AuthenticationService extends Service {}
// Don't remove this declaration: this is what enables TypeScript to resolve
// this service using `Owner.lookup('service:authentication')`, as well
// as to check when you pass the service name as an argument to the decorator,
// like `@service('authentication') declare altName: AuthenticationService;`.
declare module '@ember/service' {
interface Registry {
authentication: AuthenticationService
}
}

View file

@ -1,7 +1,10 @@
/* Ember supports plain CSS out of the box. More info: https://cli.emberjs.com/release/advanced-use/stylesheets/ */ /* Ember supports plain CSS out of the box. More info: https://cli.emberjs.com/release/advanced-use/stylesheets/ */
/* @import url("debug.css"); */
@import url("fonts.css"); @import url("fonts.css");
@import url("colors.css"); @import url("colors.css");
@import url("notes.css"); @import url("notes.css");
@import url("util.css"); @import url("util.css");
@import url("svgs.css"); @import url("svgs.css");
@import url("timeline.css"); @import url("timeline.css");
@import url("auth.css");

View file

View file

@ -0,0 +1,3 @@
* {
border: red 1px dashed;
}

View file

@ -6,12 +6,12 @@
height: fit-content; height: fit-content;
/* align-items: center; */ /* align-items: center; */
border: 1px dashed red;
/* max-width: 50em; */ /* max-width: 50em; */
padding: 0.5em; padding: 0.5em;
background-color: var(--background-100); background-color: var(--background-100);
color: var(--text); color: var(--text);
border-radius: 1em;
} }
.note-user-header { .note-user-header {
@ -23,7 +23,6 @@
} }
.note-user-pfp { .note-user-pfp {
border: 1px dashed red;
width: 3em; width: 3em;
height: 3em; height: 3em;
padding-bottom: 0.1em; padding-bottom: 0.1em;
@ -44,7 +43,7 @@
} }
.note-user-handle { .note-user-handle {
/* font-size: 85%; */ font-size: 0.8em;
color: #555; color: #555;
margin: 0; margin: 0;
} }
@ -55,7 +54,7 @@
} }
.note-timestamp { .note-timestamp {
/* font-size: 0.8em; */ font-size: 0.8em;
margin: -0.1em; margin: -0.1em;
color: var(--text-700); color: var(--text-700);
} }
@ -65,11 +64,9 @@
flex-direction: column; flex-direction: column;
width: fit-content; width: fit-content;
align-items: center; align-items: center;
border: 1px dashed red;
} }
.note-content-text { .note-content-text {
border: 1px dashed red;
margin-top: -0.08em; margin-top: -0.08em;
margin-bottom: -0.08em; margin-bottom: -0.08em;
padding: 0.2em; padding: 0.2em;
@ -80,7 +77,7 @@
margin-bottom: 0.3em; margin-bottom: 0.3em;
cursor: pointer; cursor: pointer;
background-color: var(--secondary-300); background-color: var(--secondary-300);
padding: 0.1em 0.3em 0.2em; padding: 0.1em 0.3em;
border-radius: 8px; border-radius: 8px;
border: 1px solid #aaa; border: 1px solid #aaa;
} }
@ -93,7 +90,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
border-top: 1px solid black; border-top: 1px solid var(--text-300);
padding-top: 0.5em; padding-top: 0.5em;
} }

View file

@ -5,3 +5,7 @@
scroll-behavior: smooth; scroll-behavior: smooth;
overflow-y: scroll; overflow-y: scroll;
} }
.timeline-separator {
color: var(--text-400);
}

Binary file not shown.

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter>
template block text
</Note::Formatter>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter/akoma', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter::Akoma />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter::Akoma>
template block text
</Note::Formatter::Akoma>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter/linstrom', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter::Linstrom />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter::Linstrom>
template block text
</Note::Formatter::Linstrom>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter/mastodon', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter::Mastodon />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter::Mastodon>
template block text
</Note::Formatter::Mastodon>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter/misskey', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter::Misskey />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter::Misskey>
template block text
</Note::Formatter::Misskey>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | note/formatter/wafrn', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });
await render(hbs`<Note::Formatter::Wafrn />`);
assert.dom().hasText('');
// Template block usage:
await render(hbs`
<Note::Formatter::Wafrn>
template block text
</Note::Formatter::Wafrn>
`);
assert.dom().hasText('template block text');
});
});

View file

@ -0,0 +1,17 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'frontend-reactive/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Helper | equals', function (hooks) {
setupRenderingTest(hooks);
// TODO: Replace this with your real tests.
test('it renders', async function (assert) {
this.set('inputValue', '1234');
await render(hbs`{{equals this.inputValue}}`);
assert.dom().hasText('1234');
});
});