Add language tags definition, caret and bubbles in editor.
[redakcja.git] / src / wlxml / migrations / 0002_initial_data.py
1 # Generated by Django 3.1.13 on 2021-08-13 15:44
2
3 from django.db import migrations
4
5
6 initial_tags = {
7     "section": {
8         "opowiadanie": {},
9         "powiesc": {},
10         "liryka_l": {},
11         "liryka_lp": {},
12         "dramat_wierszowany_l": {},
13         "dramat_wierszowany_lp": {},
14         "dramat_wspolczesny": {},
15         "wywiad": {},
16         "nota": {},
17         "nota_red": {
18             "editor_css": """
19             background-color: #eee;
20             border: 1px solid #888;
21             border-radius: 10px;
22             display: block;
23             padding: 0 1em 1em 1em;
24             """
25         },
26         "dedykacja": {},
27         "ramka": {},
28         "lista_osob": {},
29         "dlugi_cytat": {},
30         "poezja_cyt": {
31             "editor_css": """margin: 1.5em 2em 0;
32 font-size: 0.875em;"""
33         },
34         "kwestia": {
35             "editor_css": """
36                 margin: 5em 0 0;
37             """
38         },
39         "wywiad_pyt": {},
40         "wywiad_odp": {},
41         "motto": {
42             "editor_css": """
43                 text-align: justify;
44                 font-style: italic;
45             """
46         },
47     },
48     "div": {
49         "didaskalia": {
50             "editor_css": """font-style: italic;
51 margin: 0.5em 0 0 1.5em;"""
52         },
53         "naglowek_podrozdzial": {
54             "editor_css": """
55                 font-size: 1em;
56                 margin: 1.5em 0 0;
57                 font-weight: bold;
58                 line-height: 1.5em;
59             """
60         },
61         "naglowek_osoba": {
62             "editor_css": """
63                 font-size: 1em;
64                 margin: 1.5em 0 0;
65                 font-weight: bold;
66                 line-height: 1.5em;
67             """
68         }, 
69         "podtytul": {
70             "editor_css": """
71                 font-size: 1.5em;
72                 margin: 1.5em 0 0;
73                 font-weight: normal;
74                 line-height: 1.5em;
75             """
76         }, 
77         "naglowek_scena": {
78             "editor_css": """
79                 font-size: 1.5em;
80                 margin: 1.5em 0 0;
81                 font-weight: normal;
82                 line-height: 1.5em;
83             """
84         }, 
85         "naglowek_rozdzial": {
86             "editor_css": """
87                 font-size: 1.5em;
88                 margin: 1.5em 0 0;
89                 font-weight: normal;
90                 line-height: 1.5em;
91             """
92         }, 
93         "autor_utworu": {
94             "editor_css": """
95                 font-size: 2em;
96                 margin: 1.5em 0 0;
97                 font-weight: bold;
98                 line-height: 1.5em;
99             """
100         }, 
101         "dzielo_nadrzedne": {
102             "editor_css": """
103                 font-size: 2em;
104                 margin: 1.5em 0 0;
105                 font-weight: bold;
106                 line-height: 1.5em;
107             """
108         }, 
109         "naglowek_czesc": {
110             "editor_css": """
111                 font-size: 2em;
112                 margin: 1.5em 0 0;
113                 font-weight: bold;
114                 line-height: 1.5em;
115             """
116         }, 
117         "srodtytul": {
118             "editor_css": """
119                 font-size: 2em;
120                 margin: 1.5em 0 0;
121                 font-weight: bold;
122                 line-height: 1.5em;
123             """
124         }, 
125         "naglowek_akt": {
126             "editor_css": """
127                 font-size: 2em;
128                 margin: 1.5em 0 0;
129                 font-weight: bold;
130                 line-height: 1.5em;
131             """
132         }, 
133         "nazwa_utworu": {
134             "editor_css": """
135                 font-size: 3em;
136                 margin: 1.5em 0;
137                 text-align: center;
138                 line-height: 1.5em;
139                 font-weight: bold;
140             """,
141         }, 
142         "naglowek_listy": {}, 
143         "lista_osoba": {}, 
144         "miejsce_czas": {
145             "editor_css": """font-style: italic;""",
146         }, 
147         "akap": {
148             "editor_css": """
149                 text-align: justify;
150                 margin: 1.5em 0 0;
151             """
152         }, 
153         "akap_cd": {
154             "editor_css": """
155                 text-align: justify;
156                 margin: 1.5em 0 0;
157             """
158         }, 
159         "akap_dialog": {
160             "editor_css": """
161                 text-align: justify;
162                 margin: 1.5em 0 0;
163             """
164         }, 
165         "motto_podpis": {
166             "editor_css": """
167                 position: relative;
168                 right: -3em;
169                 text-align: right;
170             """
171         }, 
172         "uwaga": {}, 
173         "extra": {},
174     },
175     "verse": {
176         "wers_cd": {}, 
177         "wers_akap": {
178             "editor_css": """padding-left: 1em;"""
179         }, 
180         "wers_wciety": {}, 
181         "wers_do_prawej": {
182             "editor_css": """
183                 text-align: right;
184             """
185         }, 
186         "wers": {},
187     },
188     "span": {
189         "tytul_dziela": {
190             "editor_css": """font-style: italic;"""
191         }, 
192         "wyroznienie": {
193             "editor_css": """font-style: italic;
194 letter-spacing: 0.1em;"""
195         }, 
196         "slowo_obce": {
197             "editor_css": """font-style: italic;"""
198         }, 
199         "mat": {
200             "editor_css": """font-style: italic;"""
201         }, 
202         "didask_tekst": {}, 
203         "osoba": {
204             "editor_css": """font-style: normal;
205 font-variant: small-caps;"""
206         }, 
207         "wyp_osoba": {}, 
208         "www": {}, 
209         "wieksze_odstepy": {
210             "editor_css": """font-style: normal;
211 word-spacing: 1em;"""
212         }, 
213         "indeks_dolny": {
214             "editor_css": """font-style: normal;
215 vertical-align: sub;
216 font-size: .9em;"""
217         }, 
218         "zastepnik_wersu": {},
219     },
220     "sep": {
221         "sekcja_swiatlo": {
222             "editor_css": """
223             margin: 2em 0;
224             visibility: hidden;
225             """
226         }, 
227         "sekcja_asterysk": {
228             "editor_css": """
229             border: none;
230             text-align: center;
231             """,
232             "editor_css_after": """
233             content: "*";
234             """
235         }, 
236         "separator_linia": {
237             "editor_css": """
238             margin: 1.5em 0;
239             border: none;
240             border-bottom: 0.1em solid #000;
241             """
242         },
243     },
244     "aside": {
245         "pr": {}, 
246         "pa": {}, 
247         "pe": {}, 
248         "pt": {},
249     }
250
251     # To nie są wszystkie tagi.
252     # Brakuje:
253     # strofa?
254     # motyw,begin,end?
255     # ref?
256 }
257
258
259 def create_tags(apps, schema_editor):
260     Tag = apps.get_model('wlxml', 'Tag')
261     for tag_type, tags in initial_tags.items():
262         for name, props in tags.items():
263             Tag.objects.create(
264                 type=tag_type,
265                 name=name,
266                 **props
267             )
268
269
270 class Migration(migrations.Migration):
271
272     dependencies = [
273         ('wlxml', '0001_initial'),
274     ]
275
276     operations = [
277         migrations.RunPython(
278             create_tags,
279             migrations.RunPython.noop
280         )
281     ]