misc.xqm 15.6 KB
Newer Older
Mathias Goebel's avatar
Mathias Goebel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
xquery version "3.1";

module namespace f-misc="http://fontane-nb.dariah.eu/ns/SADE/misc";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace xhtml="http://www.w3.org/1999/xhtml";

declare function f-misc:cite($node as node(), $model as map(*)) {
let $url := request:get-url(),
    $res := tokenize($url, '/')[last()],
    $id := request:get-parameter('id', ''),
    $page := request:get-parameter('page', 'outer_front_cover'),
    $page := if($page = '') then 'outer_front_cover' else $page,
    $page := switch ($page)
               case "outer_front_cover" return "vordere Einbanddecke außen"
               case "inner_front_cover" return "vordere Einbanddecke innen"
               case "inner_back_cover" return "hintere Einbanddecke außen"
               case "outer_back_cover" return "hintere Einbanddecke innen"
               case "spine" return "Buchrücken"
               default return 'Blatt '||$page,
    $doc := doc( config:get("data-dir")||$id),
    $title := $doc//tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title/string(),
    $version := string( ($doc//tei:TEI/tei:teiHeader/tei:revisionDesc/tei:change/text())[1] ),
    $date := current-date(),
    $date := day-from-date($date)||'.'||month-from-date($date)||'.'||year-from-date($date),
    $url := replace($url, 'localhost:8080/exist/apps/SADE/textgrid', 'fontane-nb.dariah.eu') ||(if (request:get-query-string()) then '?' || request:get-query-string() else '')

return
    switch ($res)
    case 'edition.html'
        return
            <span>
                <a href="#" data-toggle="modal" data-target="#citation">Zitationsempfehlung</a>
                <!-- Modal window: -->
                <div class="modal fade" id="citation" tabindex="-1" role="dialog" aria-labelledby="citationrecommendation" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">Zitationsempfehlung</h4>
                        <div class="clearfix"></div>
                      </div>
                      <div class="modal-body">
                        Theodor Fontane: {$title}. Hrsg. von Gabriele Radecke.
                        In: Theodor Fontane: Notizbücher. Digitale genetisch-kritische und kommentierte Edition.
                        Hrsg. von Gabriele Radecke, {$page}.
                        {$url},
                        abgerufen am: {$date}
                      </div>
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!-- End of modal window -->
            </span>
    case 'inhalt.html'
        return
            <span>
                <a href="#" data-toggle="modal" data-target="#citation">Zitationsempfehlung</a>
                <!-- Modal window: -->
                <div class="modal fade" id="citation" tabindex="-1" role="dialog" aria-labelledby="citationrecommendation" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">Zitationsempfehlung</h4>
                        <div class="clearfix"></div>
                      </div>
                      <div class="modal-body">
                        Theodor Fontane: {$title} (Inhaltsverzeichnis). Hrsg. von Gabriele Radecke.
                        {$url},
                        abgerufen am: {$date}
                      </div>
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!-- End of modal window -->
            </span>
    case 'doku.html'
        return
            <span>
                <a href="#" data-toggle="modal" data-target="#citation">Zitationsempfehlung</a>
                <!-- Modal window: -->
                <div class="modal fade" id="citation" tabindex="-1" role="dialog" aria-labelledby="citationrecommendation" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">Zitationsempfehlung</h4>
                        <div class="clearfix"></div>
                      </div>
                      <div class="modal-body">
                        Gabriele Radecke unter Mitarbeit von Martin de la Iglesia und Mathias Göbel: Editorische Gesamtdokumentation.
                        Editorische Assistenz: Rahel Rami und Judith Michaelis. In: Theodor Fontane: Notizbücher. Digitale
                        genetisch-kritische und kommentierte Edition. Hrsg. von Gabriele Radecke.
                        {$url}, abgerufen am {$date}
                      </div>
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!-- End of modal window -->
            </span>
    default
        return
            <span>
                <a href="#" data-toggle="modal" data-target="#citation">Zitationsempfehlung</a>
                <!-- Modal window: -->
                <div class="modal fade" id="citation" tabindex="-1" role="dialog" aria-labelledby="citationrecommendation" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">Zitationsempfehlung</h4>
                        <div class="clearfix"></div>
                      </div>
                      <div class="modal-body">
                        Theodor Fontane: Notizbücher. Hrsg. von Gabriele Radecke.<br/>
                        {$url}<br/>
                        abgerufen am: {$date}
                      </div>
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!-- End of modal window -->
            </span>
};

declare function f-misc:kaesten($node as node(), $model as map(*)){
    let $q := request:get-parameter('n', '')
    let $q := if(string-length($q) = 1) then $q||"0" else $q
    let $num := if(matches($q, "\d+$")) then number(substring($q, 2, 2)) else 0
    let $q := substring($q, 1, 1)
    let $data-dir := config:get("data-dir")
return

    (<ul class="nav nav-tabs">
        {for $kasten in (('a', 'b', 'c', 'd', 'e'))
        return
            if ($q = $kasten)
            then
                <li class="active">
                    <a href="#{$kasten}" data-toggle="tab">Kasten {upper-case($kasten)}</a>
                </li>
            else
                <li>
                    <a href="#{$kasten}" data-toggle="tab">Kasten {upper-case($kasten)}</a>
                </li>
        }
    </ul>,
    <div class="tab-content">
    {
        for $kasten in (('a', 'b', 'c', 'd', 'e'))
            return
                if ($q = $kasten)
            then
        <div class="tab-pane active" id="{$kasten}">
            <div class="panel-group" id="accordion{upper-case($kasten)}" role="tablist" aria-multiselectable="true">
                    {f-misc:list( $data-dir || '/xml/meta', upper-case($kasten), $num)}
            </div>
        </div>
        else
        <div class="tab-pane" id="{$kasten}">
            <div class="panel-group" id="accordion{upper-case($kasten)}" role="tablist" aria-multiselectable="true">
                {f-misc:list($data-dir || '/xml/meta', upper-case($kasten), $num)}
            </div>
        </div>
    }
    </div>)
};
declare function f-misc:list($datadir, $param, $num as xs:integer) {
    let $tgnav:= doc('/db/sade-projects/textgrid/navigation-fontane.xml')

    for $item at $pos in distinct-values($tgnav//object[string(@type)="text/xml"][starts-with(string(@title), 'Notizbuch ' || $param)]/string(@title))
(:
 :  use these lines, when more than on revision is in the database
 :    let $maxRev:=  max($tgnav//object[@title = $item]/number(substring-after(@uri, '.'))),:)
(:    $uri:= $tgnav//object[@title = $item][number(substring-after(@uri, '.')) = $maxRev]/substring-after(@uri, 'textgrid:'):)
    let $uri:= $tgnav//object[string(@title) = $item]/substring-before(substring-after(@uri, 'textgrid:'), '.')
    return
        <div class="panel panel-dark">
                    <div class="panel-heading" role="tab" id="heading{$param||$pos}">
                      <h3 class="panel-title">
                      <a role="button" data-toggle="collapse" data-parent="#accordion{$param}" href="#collapse{$param||$pos}" aria-expanded="false" aria-controls="collapse{$param||$pos}">
                      { if (matches($item, '0\d')) then replace($item, '0', '') else $item }{if($param||$pos = ('C5', 'C6', 'C7')) then <xhtml:sup>beta</xhtml:sup> else ()}
                        </a>
                      </h3>
                    </div>
                    <div id="collapse{$param||$pos}" class="panel-collapse collapse {if ($param||$pos = $param||$num) then ' in' else ()}" role="tabpanel" aria-labelledby="heading{$param||$pos}">
                    <div class="panel-body">
                    <div class="row">
                        <div class="col-md-9">
                                <a href="edition.html?id=/xml/data/{$uri[last()]}.xml&amp;page=">Synoptische Ansicht</a>
                                <span style="margin-left:20px;"/>
                                <form class="form-inline" style="display:inline;" action="edition.html" metod="get">
                                    <input type="hidden" name="id" value="/xml/data/{$uri[last()]}.xml"/>
                                    <div class="form-group">

                                    <input name="page" type="text" style="border-radius:0;border-style:solid;width:40px;" placeholder="1r" data-toggle="tooltip" data-placement="bottom" title="Blattnummer"/>
                                    <button type="submit" class="btn btn-default"><i class="fa fa-chevron-right"></i></button>

                                    </div>
                                </form>
                              <br/>
                                <ul>
                                    <li><a href="mirador.html?n={$param||$pos}">Digitalisate</a></li>
                                    <li><a href="edition.html?id=/xml/data/{$uri[last()]}.xml&amp;page="
                                    onclick="createCookie('facs', 'inactive' , 180); createCookie('xml', 'inactive', 180); createCookie('trans', 'true', 180)">Transkriptionsansicht</a></li>
                                    <li>Edierter Text/Textkritischer Apparat</li>
                                    <li>TEI/XML-Ansicht: <a href="edition.html?id=/xml/data/{$uri[last()]}.xml&amp;page="
                                    onclick="createCookie('facs', 'inactive' , 180); createCookie('xml', 'true', 180); createCookie('trans', 'inactive', 180)"><i title="seitenweise" class="fa fa-file-o"></i></a> | <a href="xml.html?id=/xml/data/{$uri[last()]}.xml"><i title="gesamtes XML auf der Webseite betrachten" class="fa fa-file-code-o"></i></a> |<a target="_blank" href="/rest/data/{$uri[last()]}.xml">REST</a></li>
                                    <li>Kommentare und Register
                                        <ul>
                                            <li><a href="ueberblickskommentar.html?id=/xml/data/{$uri[last()]}.xml">Überblickskommentar</a></li>
                                            <li>Stellenkommentar</li>
                                            <li>Register
                                                <ul>
                                                    <li><a href="register.html?nb={$uri[last()]}&amp;r=253sx">Register der Personen und Werke</a></li>
                                                    <li><a href="register.html?nb={$uri[last()]}&amp;r=253t3">Register der Werke</a></li>
                                                    <li>Register der Werke Theodor Fontanes</li>
                                                    <li>Register der Periodika</li>
                                                    <li><a href="register.html?nb={$uri[last()]}&amp;r=253t2">Geographisches Register</a></li>
                                                    <li><a href="register.html?nb={$uri[last()]}&amp;r=253t0">Register der Ereignisse</a></li>
                                                    <li><a href="register.html?nb={$uri[last()]}&amp;r=253t1">Register der Institutionen und Körperschaften</a></li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </li>
                                    <li><a href="inhalt.html?id=/xml/data/{$uri[last()]}.xml">Inhaltsverzeichnis</a></li>
                                </ul>
                        </div>
                        <div class="col-md-3">
                            <div id="thumb">
                                {if ($param||$pos = 'C7') then
                                  (<a href="#" data-toggle="modal" data-target="#modal"><img src="/public/img/loader.svg" data-original="digilib/{substring-after($item, ' ')}_001.jpg?dh=350&amp;mo=jpg"/></a>,
                                            <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="citationrecommendation" aria-hidden="true">
                                              <div class="modal-dialog">
                                                <div class="modal-content">
                                                  <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                                                    <h4 class="modal-title">{ if (matches($item, '0\d')) then replace($item, '0', '') else $item }</h4>
                                                    <div class="clearfix"></div>
                                                  </div>
                                                  <div class="modal-body">
                                                        {doc('/db/sade-projects/textgrid/data/xml/xhtml/16b00/outer_front_cover.xml')//xhtml:div[@id="outer_front_cover"][@class="surface "]}
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                            )
                            else <img class="imgLazy" src="/public/img/loader.svg" data-original="digilib/{substring-after($item, ' ')}_001.jpg?dh=350&amp;mo=jpg"/>

                                }

                            </div>
                        </div>
                    </div>
                    </div>
                    </div>
                  </div>
};