Skip to content

Commit 46616bb

Browse files
author
jin
committed
text templates refactoring
1 parent d04315c commit 46616bb

8 files changed

+115
-64
lines changed

app/app.view.tree

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ $piterjs_app $mol_view
7070
meetup <= meetup*
7171
Meetup_texts* $piterjs_meetup_texts
7272
meetup <= meetup*
73+
Meetup_templates* $piterjs_meetup_templates
74+
meetup <= meetup*
7375
Meetup_stats* $piterjs_meetup_stats
7476
meetup <= meetup*
7577
meetup_prev <= meetup_prev* $piterjs_meetup

app/app.view.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace $.$$ {
4040

4141
guests() { return this.$.$mol_state_arg.value( 'guests' ) !== null }
4242
texts() { return this.$.$mol_state_arg.value( 'texts' ) !== null }
43+
templates() { return this.$.$mol_state_arg.value( 'templates' ) !== null }
4344
stats() { return this.$.$mol_state_arg.value( 'stats' ) !== null }
4445

4546
safe() { return this.$.$mol_state_arg.value( 'safe' ) !== null }
@@ -83,6 +84,7 @@ namespace $.$$ {
8384
... this.video() ? [ this.Video() ] : [] ,
8485
... this.guests() ? [ this.Meetup_guests( this.meetup_id() ) ] : [] ,
8586
... this.texts() ? [ this.Meetup_texts( this.meetup_id() ) ] : [] ,
87+
... this.templates() ? [ this.Meetup_templates( this.meetup_id() ) ] : [] ,
8688
... this.stats() ? [ this.Meetup_stats( this.meetup_id() ) ] : [] ,
8789
... this.others() ? [ this.Others() ] : [] ,
8890
... this.wiki() ? this.Wiki().pages() : [],

meetup/meetup.ts

+50-2
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,56 @@ namespace $ {
216216
}
217217

218218
@ $mol_mem
219-
init_text( next?: string ) {
220-
return this.sub( 'init_text', $hyoo_crowd_reg ).str( next )
219+
init_template( next?: string ) {
220+
return this.sub( 'init_template', $hyoo_crowd_text ).text( next ) || `
221+
Ура! Скоро **PiterJS {title}**
222+
223+
{descr}
224+
225+
⏰ Когда: **{start}**
226+
📍 Где: {place} (**{address}**)
227+
228+
📰 Программа
229+
230+
{speeches}
231+
232+
🎫 Регистрация: {register}
233+
`.replace( /\t/g, '' ).trim()
234+
}
235+
236+
@ $mol_mem
237+
init_speech_template( next?: string ) {
238+
return this.sub( 'init_speech_template', $hyoo_crowd_text ).text( next ) || `
239+
🗣️ {start} {speaker}
240+
🎤 **{title}**
241+
`.replace( /\t/g, '' ).trim()
242+
}
243+
244+
@ $mol_mem
245+
init_text() {
246+
247+
const title = this.title()
248+
const descr = this.description()
249+
const start = this.start()?.toString( 'DD Month hh:mm' ) ?? 'скоро'
250+
const place = this.place().title()
251+
const address = this.place().address()
252+
const register = this.$.$mol_state_arg.make_link({ meetup: this.id() })
253+
const speeches = this.speeches().map(
254+
speech => this.init_speech_template()
255+
.replaceAll( '{start}', speech.start().toString( 'hh:mm' ) )
256+
.replaceAll( '{speaker}', speech.speaker().title() )
257+
.replaceAll( '{title}', speech.title() )
258+
).join( '\n\n' ) || 'формируется'
259+
260+
return this.init_template()
261+
.replaceAll( '{title}', title )
262+
.replaceAll( '{descr}', descr )
263+
.replaceAll( '{start}', start )
264+
.replaceAll( '{place}', place )
265+
.replaceAll( '{address}', address )
266+
.replaceAll( '{speeches}', speeches )
267+
.replaceAll( '{register}', register )
268+
221269
}
222270

223271
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace $.$$ {
2+
3+
$mol_style_define( $piterjs_meetup_templates, {
4+
5+
flex: {
6+
basis: `30rem`,
7+
},
8+
9+
} )
10+
11+
}

meetup/templates/templates.view.tree

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$piterjs_meetup_templates $mol_page
2+
theme \$mol_theme_special
3+
meetup $piterjs_meetup
4+
init_text => init_text
5+
init_template? => init_template?
6+
init_speech_template? => init_speech_template?
7+
title \Шаблоны текстов
8+
tools /
9+
<= Close $mol_link
10+
arg * templates null
11+
sub /
12+
<= Close_icon $mol_icon_close
13+
body /
14+
<= Content $mol_list rows /
15+
<= Init_template_labeler $mol_labeler
16+
title \Шаблон анонса мероприятия
17+
Content <= Init_template $mol_textarea
18+
value? <=> init_template?
19+
<= Init_speech_template_labeler $mol_labeler
20+
title \Шаблон доклада в анонсе
21+
Content <= Init_speech_template $mol_textarea
22+
value? <=> init_speech_template?

meetup/texts/texts.view.css.ts

+11
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@ namespace $.$$ {
88

99
} )
1010

11+
$mol_style_define( $piterjs_meetup_texts_card, {
12+
13+
Text: {
14+
whiteSpace: 'pre',
15+
background: {
16+
color: $mol_theme.card,
17+
},
18+
},
19+
20+
} )
21+
1122
}

meetup/texts/texts.view.tree

+17-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
$piterjs_meetup_texts $mol_page
22
theme \$mol_theme_special
33
meetup $piterjs_meetup
4-
title \Тексты анонсов
4+
init_text => init_text
5+
init_template? => init_template?
6+
init_speech_template? => init_speech_template?
7+
title \Тексты постов
58
tools /
9+
<= Templates $mol_link
10+
arg * templates \
11+
sub /
12+
<= Templates_icon $mol_icon_pencil_outline
613
<= Close $mol_link
714
arg * texts null
815
sub /
916
<= Close_icon $mol_icon_close
10-
speech_text* \
11-
\🎤 {start} {speaker} **{title}**
1217
body /
1318
<= Content $mol_list rows /
14-
<= Init_labeler $mol_section
19+
<= Init_text $piterjs_meetup_texts_card
1520
title \Анонс мероприятия
16-
tools /
17-
<= init_copy $mol_button_copy
18-
text <= init_text
19-
Content <= Init_field $mol_textarea
20-
value? <=> init_text? \
21-
\Ура! Скоро PiterJS {title}
22-
\
23-
\{descr}
24-
\
25-
\⏰ Когда: {start}
26-
\📍 Где: {place} ({address})
27-
\
28-
\📰 Программа
29-
\
30-
\{program}
31-
\
32-
\🎫 Регистрация: {register}
21+
text <= init_text
22+
23+
$piterjs_meetup_texts_card $mol_section
24+
tools /
25+
<= Copy $mol_button_copy
26+
text <= text \
27+
content / <= Text $mol_text
28+
text <= text \

meetup/texts/texts.view.ts

-41
This file was deleted.

0 commit comments

Comments
 (0)