Move files around, formatter helper
Formatters for username belong to account, not to note New helper for transforming a markdown text to html
This commit is contained in:
parent
5fb5dae31e
commit
c919cc8c67
16 changed files with 69 additions and 27 deletions
|
@ -9,7 +9,7 @@
|
|||
[admin]
|
||||
username = "server-admin"
|
||||
first_time_setup_otp = "Example otp password"
|
||||
profiling_password = "Example profiling password"
|
||||
profiling_password = ""
|
||||
|
||||
[webauthn]
|
||||
display_name = "Linstrom"
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<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>
|
16
frontend-reactive/app/components/util/formatter.hbs
Normal file
16
frontend-reactive/app/components/util/formatter.hbs
Normal file
|
@ -0,0 +1,16 @@
|
|||
<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>
|
24
frontend-reactive/app/helpers/formatter.ts
Normal file
24
frontend-reactive/app/helpers/formatter.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { helper } from '@ember/component/helper'
|
||||
|
||||
class Token {
|
||||
declare token: string
|
||||
declare elements: Array<string | Token>
|
||||
|
||||
public constructor(token: string) {
|
||||
this.token = token
|
||||
this.elements = new Array()
|
||||
}
|
||||
}
|
||||
|
||||
export default helper(function formatter(
|
||||
positional: Array<string>,
|
||||
named: {
|
||||
matchers: Array<{ match: RegExp; replace: string }>
|
||||
},
|
||||
): string {
|
||||
let out = positional[0] ?? ''
|
||||
named.matchers.forEach((x) => {
|
||||
out = out.replaceAll(x.match, x.replace)
|
||||
})
|
||||
return out
|
||||
})
|
|
@ -1,26 +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'
|
||||
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 | account/profilepicture', function (hooks) {
|
||||
setupRenderingTest(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`<Account::Header::Profilepicture />`)
|
||||
await render(hbs`<Account::Header::Profilepicture />`);
|
||||
|
||||
assert.dom().hasText('')
|
||||
assert.dom().hasText('');
|
||||
|
||||
// Template block usage:
|
||||
await render(hbs`
|
||||
<Account::Profilepicture>
|
||||
template block text
|
||||
</Account::Profilepicture>
|
||||
`)
|
||||
`);
|
||||
|
||||
assert.dom().hasText('template block text')
|
||||
})
|
||||
})
|
||||
assert.dom().hasText('template block text');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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 | tokeniseContent', function (hooks) {
|
||||
setupRenderingTest(hooks)
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it renders', async function (assert) {
|
||||
this.set('inputValue', '1234')
|
||||
|
||||
await render(hbs`{{formatter this.inputValue}}`)
|
||||
|
||||
assert.dom().hasText('1234')
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue