Skip to content

Commit cc4ff1c

Browse files
committed
fix whitespace and other small tweaks
1 parent daaaaa9 commit cc4ff1c

File tree

5 files changed

+221
-220
lines changed

5 files changed

+221
-220
lines changed

src/App.svelte

+136-130
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,80 @@
11
<script>
2-
import {querystring, push} from 'svelte-spa-router'
3-
import {parse} from 'qs'
4-
import Table from './Table.svelte'
5-
import {get_template_keys, get_citation, get_template_map} from './utils.js'
6-
import {supported_languages} from './languages.js'
7-
let source = parse($querystring).source || ''
8-
let language = parse($querystring).lang || 'en'
9-
let template
10-
let template_map
11-
12-
$: template_map_promise = get_template_map(language).then(data => {
13-
template_map = data
14-
return data
15-
})
16-
$: source_promise = get_citation(source).then(data => {
17-
if (data[0]) {
18-
var item_type = data[0].itemType
19-
template = template_map[item_type]
20-
21-
}
22-
return data
23-
})
24-
25-
$: template_promise = get_template_keys(language, 'Template:' + template)
26-
27-
$: push('/?lang=' + language + '&source=' + source)
2+
import {querystring, push} from 'svelte-spa-router'
3+
import {parse} from 'qs'
4+
import Table from './Table.svelte'
5+
import {get_template_keys,
6+
get_citation,
7+
get_template_map} from './utils.js'
8+
import {supported_languages} from './languages.js'
289
10+
let source = parse($querystring).source || ''
11+
let language = parse($querystring).lang || 'en'
12+
let template
13+
let template_map
14+
15+
$: template_map_promise = get_template_map(language).then(data => {
16+
template_map = data
17+
return data
18+
})
19+
$: source_promise = get_citation(source).then(data => {
20+
if (data[0]) {
21+
var item_type = data[0].itemType
22+
template = template_map[item_type]
23+
}
24+
return data
25+
})
26+
$: template_promise = get_template_keys(language, 'Template:' + template)
27+
$: push('/?lang=' + language + '&source=' + source)
2928
</script>
3029

3130
<style>
32-
:global(body) {
33-
line-height: 1.5em;
34-
35-
}
36-
:global(a, a:visited) {
37-
color: #181b1f;
38-
text-decoration: none;
31+
:global(body) {
32+
line-height: 1.5em;
33+
}
34+
:global(a, a:visited) {
35+
color: #181b1f;
36+
text-decoration: none;
3937
background-image: linear-gradient(to bottom, #03a9f4 50%, #03a9f4 50%);
4038
background-repeat: repeat-x;
4139
background-size: 1px 2px;
4240
background-position: 0 100%;
4341
transition: color 1s ease;
44-
}
45-
:global(a:hover) {
46-
text-decoration: none;
47-
color: #03a9f4;
48-
transition: color 1s ease;
49-
}
50-
input {
51-
width: 100%;
52-
}
53-
label {
54-
font-weight: bold
55-
}
56-
li {
57-
margin-bottom: 0.2em;
58-
}
59-
h2 {
60-
padding: 1em 0 0 0;
61-
border-top: 7px solid #181b1f;
62-
}
63-
.body {
64-
max-width: 600px;
65-
margin: 5em auto;
66-
border-radius: 5px;
67-
border: 1px solid #c4cdd4;
68-
padding: 1em;
69-
}
70-
.loading {
71-
padding: 5em;
72-
text-align: center;
73-
border-top: 7px solid #181b1f;
74-
}
42+
}
43+
:global(a:hover) {
44+
text-decoration: none;
45+
color: #03a9f4;
46+
transition: color 1s ease;
47+
}
48+
49+
input {
50+
width: 100%;
51+
}
52+
label {
53+
font-weight: bold
54+
}
55+
li {
56+
margin-bottom: 0.2em;
57+
}
58+
h2 {
59+
padding: 1em 0 0 0;
60+
border-top: 7px solid #181b1f;
61+
}
62+
63+
.body {
64+
max-width: 600px;
65+
margin: 5em auto;
66+
border-radius: 5px;
67+
border: 1px solid #c4cdd4;
68+
padding: 1em;
69+
}
70+
.loading {
71+
padding: 5em;
72+
text-align: center;
73+
border-top: 7px solid #181b1f;
74+
}
75+
.search {
76+
77+
}
7578
</style>
7679

7780
<svelte:head>
@@ -80,72 +83,75 @@
8083
</svelte:head>
8184

8285
<div class="body">
83-
<h1>
84-
Wikipedia Source Debug Tool
85-
</h1>
86+
<div class="search">
87+
<h1>Wikipedia Source Debug Tool</h1>
88+
89+
<p>Use this debug tool to see what information <a href="https://www.mediawiki.org/wiki/Citoid">Citoid</a> can detect when generating a Wikipedia citation. Provide your URL, DOI, ISBN, PMC/PMID, QID, title, or citation.</p>
90+
91+
<label>Source</label>
92+
<input bind:value={source} >
93+
<label>Wikipedia Langauge:</label>
94+
<select bind:value={language}>
95+
{#each supported_languages as supported_language}
96+
<option value="{supported_language.code}">{supported_language.name}</option>
97+
{/each}
98+
</select>
99+
</div>
100+
101+
{#await template_map_promise}
102+
<p class="loading">...loading template_map for {language}</p>
103+
{:then d_template_map}
104+
{#await source_promise}
105+
<p class="loading">...loading source data for {source}</p>
106+
{:then data}
107+
{#if source}
108+
{#await template_promise}
109+
<p class="loading">
110+
...loading template data for {template}
111+
</p>
112+
{:then keys}
113+
114+
<h2>Detected: {data[0].itemType} / Template:{template}</h2>
115+
116+
<h3>Available data</h3>
117+
<Table data={data[0]} {keys}/>
86118

87-
<p>Use this debug tool to see what information <a href="https://www.mediawiki.org/wiki/Citoid">Citoid</a> can detect when generating a Wikipedia citation. Provide your URL, DOI, ISBN, PMC/PMID, QID, title, or citation.</p>
88-
<div class="search">
89-
<label>Source</label>
90-
<input bind:value={source} >
91-
<label>Wikipedia Langauge:</label>
92-
<select bind:value={language}>
93-
{#each supported_languages as supported_language}
94-
<option value="{supported_language.code}">{supported_language.name}</option>
95-
{/each}
96-
</select>
97-
</div>
119+
<h3>Missing data</h3>
120+
<p>Supporting more, relevant fields will produce better citations for Wikipedia. Fields supported by <a href="https://{language}.wikipedia.org/wiki/Template:{template}">{template}</a> ({language}) and missing from this source:</p>
121+
<ul>
122+
{#each keys as key}
123+
{#if data && !Object.keys(data[0]).includes(key)}
124+
<li>{key}</li>
125+
{/if}
126+
{/each}
127+
</ul>
98128

99-
{#await template_map_promise}
100-
<p class="loading">
101-
...loading template_map for {language}
102-
</p>
103-
{:then d_template_map}
104-
{#await source_promise}
105-
<p class="loading">
106-
...loading source data for {source}
107-
</p>
108-
{:then data}
109-
{#if source}
110-
{#await template_promise}
111-
<p class="loading">
112-
...loading template data for {template}
113-
</p>
114-
{:then keys}
115-
<h2>Detected: {data[0].itemType} / Template:{template}</h2>
116-
<h3>Available data</h3>
117-
<Table data={data[0]} {keys}/>
129+
<h2>How can I improve this source for Wikipedia?</h2>
130+
<p>Did you notice something wrong? Are there relevant fields that aren't included?</p>
131+
<ul>
132+
<li>Make the source Zotero-compatible: <a href="https://www.zotero.org/support/dev/exposing_metadata">learn more about adding or fixing Zotero metadata</a>.</li>
133+
<li>Improve the Zotero translator for this source: <a href="https://github.com/wikimedia/mediawiki-services-zotero-translators">see the source code for Wikipedia's Zotero service</a>, and see Wikimedia's <a href="https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators">guide for creating Zotero translators</a>.</li>
134+
</ul>
135+
<!--
136+
<h2>Dumps!!</h2>
137+
<h3>Template Map</h3>
138+
{JSON.stringify(d_template_map)}
139+
<h3>Source data</h3>
140+
{JSON.stringify(data)}
141+
<h3>Template keys</h3>
142+
{JSON.stringify(keys)}
143+
-->
144+
{:catch error}
145+
{error}
146+
{/await}
147+
{/if}
148+
{:catch error}
149+
{error}
150+
{/await}
151+
{:catch error}
152+
{error}
153+
{/await}
118154

119-
<h3>Missing data</h3>
120-
<p>Supporting more, relevant fields will produce better citations on Wikipedia. Fields supported by <a href="https://{language}.wikipedia.org/wiki/Template:{template}">{template}</a> ({language}) and missing from this source:
121-
</p>
122-
<ul>
123-
{#each keys as key}
124-
{#if data && !Object.keys(data[0]).includes(key)}
125-
<li>{key}</li>
126-
{/if}
127-
{/each}
128-
</ul>
129-
<h2>How can I improve this source on Wikipedia?</h2>
130-
<p>Did you notice something wrong? Are there relevant fields that aren't included?</p>
131-
<ul>
132-
<li>Make the source Zotero-compatible: <a href="https://www.zotero.org/support/dev/exposing_metadata">learn more about adding or fixing Zotero metadata</a>.</li>
133-
<li>Improve the Zotero translator for this source: <a href="https://github.com/wikimedia/mediawiki-services-zotero-translators">see the source code for Wikipedia's Zotero service</a>, and see Wikimedia's <a href="https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators">guide for creating Zotero translators</a>.</li>
134-
</ul>
135-
{:catch error}
136-
{error}
137-
{/await}
138-
{/if}
139-
{:catch error}
140-
{error}
141-
{/await}
142-
{:catch error}
143-
{error}
144-
{/await}
145-
<h2>
146-
About
147-
</h2>
148-
<p>
149-
The source code is <a href="https://github.com/hatnote/source-debug">available on github</a>. This tool was built by <a href="https://github.com/slaporte">Stephen LaPorte</a> at <a href="https://wikiconference.org/wiki/2019/Main_Page">WikiConference North America 2019</a>. Thanks to <a href="https://twitter.com/fuzheado">@fuzheado</a> for the idea.
150-
</p>
151-
</div>
155+
<h2>About</h2>
156+
<p>The source code is <a href="https://github.com/hatnote/source-debug">available on github</a>. This tool was built by <a href="https://github.com/slaporte">Stephen LaPorte</a> at <a href="https://wikiconference.org/wiki/2019/Main_Page">WikiConference North America 2019</a>. Thanks to <a href="https://twitter.com/fuzheado">@fuzheado</a> for the idea.</p>
157+
</div>

src/Table.svelte

+27-30
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
1-
2-
31
<script>
4-
export let data
5-
export let keys
6-
let entries = Object.entries(data)
2+
export let data
3+
export let keys
4+
5+
let entries = Object.entries(data)
76
</script>
87

98
<style>
10-
table {
11-
border-collapse: collapse;
12-
}
13-
table, th, td {
14-
border: 1px solid #a0b4cb;
15-
padding: 0.75em;
16-
}
17-
th {
18-
color: #666;
19-
background: #edf7ff;
20-
}
9+
table {
10+
border-collapse: collapse;
11+
}
12+
table, th, td {
13+
border: 1px solid #a0b4cb;
14+
padding: 0.75em;
15+
}
16+
th {
17+
color: #666;
18+
background: #edf7ff;
19+
}
2120
</style>
2221

2322
<table>
24-
{#each entries as entry}
23+
{#each entries as entry}
2524
{#if !keys || keys.includes(entry[0])}
26-
<tr>
27-
{#if keys}
28-
<th>
29-
{entry[0]}
30-
</th>
31-
{/if}
32-
{#if typeof(entry[1]) == 'object'}
33-
<td><svelte:self data={entry[1]}/></td>
34-
{:else}
35-
<td>{entry[1]}</td>
36-
{/if}
37-
</tr>
25+
<tr>
26+
{#if keys}
27+
<th>{entry[0]}</th>
28+
{/if}
29+
{#if typeof(entry[1]) == 'object'}
30+
<td><svelte:self data={entry[1]}/></td>
31+
{:else}
32+
<td>{entry[1]}</td>
33+
{/if}
34+
</tr>
3835
{/if}
39-
{/each}
36+
{/each}
4037
</table>

src/languages.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// See: https://www.mediawiki.org/wiki/Citoid/Where_citoid_is_enabled
22

33
export const supported_languages = [
4-
{'code': 'en',
5-
'name': 'English'},
6-
{'code': 'es',
7-
'name': 'Spanish'},
8-
]
4+
{'code': 'en',
5+
'name': 'English'},
6+
{'code': 'es',
7+
'name': 'Spanish'},
8+
]

src/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import App from './App.svelte';
22

33
var app = new App({
4-
target: document.body
4+
target: document.body
55
});
66

7-
export default app;
7+
export default app;

0 commit comments

Comments
 (0)