Skip to content

Commit 4a65e20

Browse files
authored
Merge pull request #13 from hatnote/dev
version 17.03.02
2 parents c8e1bb9 + a17c7b9 commit 4a65e20

7 files changed

Lines changed: 124 additions & 23 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monumental",
3-
"version": "17.03.01",
3+
"version": "17.03.02",
44
"private": true,
55
"description": "Monumental app",
66
"main": "src/index.js",

src/components/main/dashboard/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ <h4 class="md-title">Showcases</h4>
144144
</p>
145145
<p layout="column" layout-align="start stretch">
146146
<strong>Games</strong>
147-
<a ui-sref="main.game.category({country: '145'})">Wikidata entry – Wikimedia Commons category matching for Great Britain</a>
147+
<a ui-sref="main.game.category()">Wikidata entry – Wikimedia Commons category matching</a>
148148
</p>
149149
</div>
150150
</div>

src/components/main/games/category/games-category.html

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
<div class="container" layout="column" layout-align="space-between stretch" flex>
1+
<div class="container" flex
2+
layout="column" layout-align="space-between stretch"
3+
ng-if="!$ctrl.country">
4+
<md-content layout="column" layout-align="start center" flex>
5+
<div class="list" layout="column" layout-align="start stretch">
6+
<div class="game__title">
7+
<h3 class="md-headline">Matching Wikidata entry with Wikimedia Commons category</h3>
8+
<h4 class="md-subhead muted">Monumental Wikidata Games</h4>
9+
</div>
10+
<div layout="row" layout-align="center center">
11+
<md-button class="md-raised" ui-sref="main.game.category({country: '142'})" flex>France</md-button>
12+
<md-button class="md-raised" ui-sref="main.game.category({country: '183'})" flex>Germany</md-button>
13+
<md-button class="md-raised" ui-sref="main.game.category({country: '145'})" flex>Great Britain</md-button>
14+
<md-button class="md-raised" ui-sref="main.game.category({country: '36'})" flex>Poland</md-button>
15+
<md-button class="md-raised" ui-sref="main.game.category({country: '30'})" flex>United States</md-button>
16+
</div>
17+
</div>
18+
</md-content>
19+
</div>
20+
<div class="container" flex
21+
layout="column" layout-align="space-between stretch"
22+
ng-if="$ctrl.country">
23+
<div class="game__reminder"
24+
layout="column" layout-align="start stretch"
25+
ng-if="$ctrl.isReminderShown">
26+
<span>Please choose the category that is <strong>specifically</strong> for photos of the monument. If the category doesn't exist, you can skip it for now.</span>
27+
<md-button ng-if="$ctrl.isReminderShown !== 'check'" ng-click="$ctrl.isReminderShown = 'check'">got it</md-button>
28+
<md-button ng-if="$ctrl.isReminderShown === 'check'" ng-click="$ctrl.isReminderShown = false">you sure?</md-button>
29+
</div>
230
<div layout="column" layout-align="start stretch" flex="none" ng-if="!$ctrl.error">
331
<div class="game__subheader" layout="row" layout-align="center center">
432
<div class="list" layout="row" layout-align="start center">
@@ -14,20 +42,27 @@
1442
</md-input-container>
1543
<span>with image but without Wikimedia Commons category.</span>
1644
</span>
17-
<small class="muted">Click plus next to category sugestion to add it.</small>
45+
<p class="game__instructions">The goal of the game is to connect each monument on Wikidata with a category on Wikimedia Commons. For each monument (on the left), please choose the category (on the right) that is <strong>specifically for photos of the monument</strong>. If the category doesn't exist, you can skip it for now.</p>
46+
<p class="game__instructions">Click the <md-icon>add_circle_outline</md-icon> button to add the category to a monument. You can click on the name of the category to view it on Commons.</p>
1847
</div>
1948
<div flex></div>
20-
<md-button ng-if="!$ctrl.loading">
21-
<md-tooltip md-direction="bottom">This is cached value. It means it is not updated real-time.</md-tooltip>
22-
<span>{{$ctrl.total}} results</span>
23-
</md-button>
24-
<md-button ng-click="$ctrl.reload()">
25-
<md-icon>forward</md-icon> next entries
26-
</md-button>
49+
<div layout="column" layout-align="center stretch">
50+
<md-button ng-if="!$ctrl.loading">
51+
<md-tooltip md-direction="bottom">This is cached value. It means it is not updated real-time.</md-tooltip>
52+
<span>{{$ctrl.total}} results</span>
53+
</md-button>
54+
</div>
2755
</div>
2856
</div>
2957
</div>
3058
<md-content layout="column" layout-align="start center" flex>
59+
<div class="list" flex
60+
layout="row" layout-align="end center"
61+
ng-if="!$ctrl.error && !$ctrl.loading">
62+
<md-button flex ng-click="$ctrl.reload()">
63+
<md-icon>forward</md-icon> next entries
64+
</md-button>
65+
</div>
3166
<div class="list" flex
3267
layout="column" layout-align="start stretch"
3368
ng-if="!$ctrl.error && !$ctrl.loading">
@@ -49,26 +84,27 @@
4984
<span><span>{{ ::item.place }}</span><span ng-if="item.place && item.admin"> · </span><span>{{ ::item.admin }}</span></span>
5085
</p>
5186
<div flex layout="column" layout-align="start stretch">
87+
<p class="list__category muted" ng-if="!item.categories.length"><span class="muted">No suggestions</span></p>
5288
<p class="list__category"
5389
layout="row" layout-align="start center"
5490
ng-repeat="category in item.categories"
5591
ng-class="{ 'list__category--underlined' : !$last }">
5692
<md-button class="md-primary" aria-label="Add category"
57-
ng-click="$ctrl.saveCategory(item, category)"
58-
ng-if="item.success !== category"
93+
ng-click="$ctrl.saveCategory(item, category.name)"
94+
ng-if="item.success !== category.name"
5995
ng-disabled="item.loading || item.success">
60-
<md-icon ng-if="item.loading !== category && item.success !== category">add_circle_outline</md-icon>
61-
<md-progress-circular md-mode="indeterminate" md-diameter="24px" ng-if="item.loading === category"></md-progress-circular>
62-
<md-icon ng-if="item.success === category">check_circle</md-icon>
96+
<md-icon ng-if="item.loading !== category.name && item.success !== category.name">add_circle_outline</md-icon>
97+
<md-progress-circular md-mode="indeterminate" md-diameter="24px" ng-if="item.loading === category.name"></md-progress-circular>
98+
<md-icon ng-if="item.success === category.name">check_circle</md-icon>
6399
</md-button>
64100
<md-button class="md-primary" aria-label="Category added"
65101
ng-href="//wikidata.org/w/index.php?title={{ ::item.name.value_id }}&diff=last" target="_blank"
66-
ng-if="item.success === category">
102+
ng-if="item.success === category.name">
67103
<md-tooltip md-direction="bottom">Click to see diff or revert edit</md-tooltip>
68104
<md-icon>check_circle</md-icon>
69105
</md-button>
70106
<span>
71-
<a ng-href="//commons.wikimedia.org/wiki/Category:{{ ::category }}" target="_blank">{{ ::category }}</a>
107+
<a ng-href="//commons.wikimedia.org/wiki/Category:{{ ::category.name }}" target="_blank">{{ ::category.name }}</a>
72108
</span>
73109
</p>
74110
</div>

src/components/main/games/category/games-category.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ const GamesCategoryComponent = { controller, template };
77

88
function controller($mdToast, $q, $state, $stateParams, $window, WikiService, langService, wikidata) {
99
const vm = this;
10-
const id = $stateParams.country.includes('Q') ? $stateParams.country : `Q${$stateParams.country}`;
10+
const id = getId();
1111

1212
vm.countries = [
1313
{ name: 'France', code: 'Q142' },
1414
{ name: 'Germany', code: 'Q183' },
1515
{ name: 'Great Britain', code: 'Q145' },
1616
{ name: 'Poland', code: 'Q36' },
17-
{ name: 'the USA', code: 'Q30' },
17+
{ name: 'the United States', code: 'Q30' },
1818
];
19-
vm.country = id || 'Q36';
19+
vm.country = id;
20+
vm.isReminderShown = true;
2021
vm.loading = true;
2122

2223
vm.reload = () => $state.go($state.current, { country: vm.country }, { reload: true });
2324
vm.saveCategory = saveCategory;
2425

26+
const regexes = {
27+
Q30: /(20[01][0-9] in.*|Churches in .*|National Register of Historic Places in .*|Photographs of|Photographs taken|in Alabama|in Alaska|in Arizona|in Arkansas|in California|in Colorado|in Connecticut|in Delaware|in Florida|in Georgia (U.S. state)|in Hawaii|in Idaho|in Illinois|in Indiana|in Iowa|in Kansas|in Kentucky|in Louisiana|in Maine|in Maryland|in Massachusetts|in Michigan|in Minnesota|in Mississippi|in Missouri|in Montana|in Nebraska|in Nevada|in New Hampshire|in New Jersey|in New Mexico|in New York|in North Carolina|in North Dakota|in Ohio|in Oklahoma|in Oregon|in Pennsylvania|in Rhode Island|in South Carolina|in South Dakota|in Tennessee|in Texas|in Utah|in Vermont|in Virginia|in Washington, D.C.|in West Virginia|in Wisconsin|in Wyoming|in the United States)/gi,
28+
Q36: /(20[01][0-9] in.*|Cultural heritage monuments in.*|in Greater Poland Voivodeship|in Kuyavian-Pomeranian Voivodeship|in Lesser Poland Voivodeship|in Lower Silesian Voivodeship|in Lublin Voivodeship|in Lubusz Voivodeship|in Łódź Voivodeship|in Masovian Voivodeship|in Opole Voivodeship|in Podlaskie Voivodeship|in Pomeranian Voivodeship|in Silesian Voivodeship|in Subcarpathian Voivodeship|in Świętokrzyskie Voivodeship|in Warmian-Masurian Voivodeship|in West Pomeranian Voivodeship|in Poland)/gi,
29+
Q145: /(20[01][0-9] in.*|listed [a-z]* in.*|in Bedfordshire|in Berkshire|in Bristol|in Buckinghamshire|in Cambridgeshire|in Cheshire|in Cornwall|in County Durham|in Cumbria|in Derbyshire|in Devon|in Dorset|in East Sussex|in Essex|in Gloucestershire|in Greater Manchester|in Hampshire|in Herefordshire|in Hertfordshire|on the Isle of Wight|in Kent|in Lancashire|in Leicestershire|in Lincolnshire|in London|in Merseyside|in Middlesex|in Norfolk, England|in Northamptonshire|in Northumberland|in Nottinghamshire|in Oxfordshire|in Rutland|in Shropshire|in Somerset|in Staffordshire|in Suffolk|in Surrey|in Tyne and Wear|in Warwickshire|in the West Midlands|in West Sussex|in Wiltshire|in Worcestershire|in North Yorkshire|in South Yorkshire|in the East Riding of Yorkshire|in West Yorkshire|in England|in Scotland|in the United Kingdom)/gi,
30+
};
31+
2532
init();
2633

2734
function getCategories(filenames) {
@@ -37,6 +44,15 @@ function controller($mdToast, $q, $state, $stateParams, $window, WikiService, la
3744
});
3845
}
3946

47+
function getCategoryEligibility(name) {
48+
const regex = regexes[vm.country];
49+
if (!regex) { return true; }
50+
51+
regex.lastIndex = 0;
52+
const matches = regex.exec(name.trim());
53+
return !matches;
54+
}
55+
4056
function getCountry() {
4157
wikidata.get({ ids: id })
4258
.then((response) => {
@@ -45,6 +61,13 @@ function controller($mdToast, $q, $state, $stateParams, $window, WikiService, la
4561
});
4662
}
4763

64+
function getId() {
65+
const param = $stateParams.country;
66+
if (!param) { return false; }
67+
if (param.includes('Q')) { return param; }
68+
return `Q${param}`;
69+
}
70+
4871
function getList() {
4972
const langs = langService.getNativeLanguages(id);
5073
if (!langs) { return $q.reject('Provided ID is not a country'); }
@@ -63,6 +86,8 @@ function controller($mdToast, $q, $state, $stateParams, $window, WikiService, la
6386
}
6487

6588
function init() {
89+
if (!vm.country) { return; }
90+
6691
vm.loading = true;
6792
vm.list = [];
6893

@@ -92,7 +117,12 @@ function controller($mdToast, $q, $state, $stateParams, $window, WikiService, la
92117
.then(list => getCategories(list.map(entry => entry.image.name)))
93118
.then((response) => {
94119
vm.list.forEach((element) => {
95-
element.categories = response[element.image.name];
120+
element.categories = response[element.image.name]
121+
.map(category => ({
122+
name: category,
123+
isEligible: getCategoryEligibility(category),
124+
}))
125+
.filter(category => category.isEligible);
96126
});
97127
vm.loading = false;
98128
})

src/components/main/games/games.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
@import '../../../styles/variables';
22
@import '../../../styles/responsive';
33

4+
.game__title {
5+
margin-bottom: 20px;
6+
.md-headline, .md-subhead {
7+
margin: 0;
8+
}
9+
}
10+
11+
.game__reminder {
12+
position: fixed;
13+
width: 200px;
14+
padding: 20px 20px 15px;
15+
font-size: 85%;
16+
z-index: 1;
17+
right: 10px;
18+
top: 10px;
19+
background: white;
20+
border: 1px solid #e5e5e5;
21+
border-radius: 2px;
22+
}
23+
424
mo-game-category {
525
.game__subheader {
626
padding: 15px 25px;
27+
z-index: 10;
728
background: #fafafa;
829
border-bottom: 1px solid $softGrey;
930

31+
.game__instructions {
32+
margin: 5px 0;
33+
font-size: 90%;
34+
}
35+
1036
md-input-container {
1137
margin-bottom: 0;
1238
margin-top: 0;

src/services/lang.service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ const LangService = function ($q, localStorageService) {
210210
if (userLanguages.length) { return angular.copy(userLanguages); }
211211

212212
const ls = localStorageService.get('languages');
213-
const def = navigator.language || navigator.userLanguage;
213+
let def = navigator.language || navigator.userLanguage;
214+
def = def.split('-')[0];
214215

215216
userLanguages = ls || [def];
216217
if (!userLanguages.includes('en')) { userLanguages.push('en'); }

src/styles/_general.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ small {
7373
text-align: right;
7474
}
7575

76+
.text-small {
77+
font-size: small;
78+
79+
&p {
80+
margin: 5px 0;
81+
}
82+
}
83+
7684
.invisible {
7785
width: 0;
7886
height: 0;

0 commit comments

Comments
 (0)