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
|
#!/usr/bin/env bash
# This file is part of FreeAMO
# Copyright (C) 2018 David Hedlund
#
# FreeAMO is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FreeAMO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cd "build/json/search-pages" || exit
if [ "$minimum_average_daily_users" == "100000" ]; then
echo "{| class=\"wikitable sortable\" border=\"1\" style=\"font-size:smaller\"
! WebExtension
! Description
! Claimed license
! Users
! Rating
! Updated
! Featured" > "$run_path/build/IceCat WebExtensions - Most Users (proposed).wiki"
fi
output_file="$output_file_2";
if [ "$debug" = true ]; then
pv__size=$(cat "$output_file_2" | head -n 3 | wc -l)
else
pv__size=$(cat "$output_file_2" | wc -l)
fi
source "$run_path/src/main_functions"
echo "Generate $pv__size .wiki pages."
line=0
while IFS= read -r table; do
((++line))
if [ "$debug" = true ] && [ "$line" -le "3" ] || [ "$debug" = false ] ; then
file=$(echo "$table" | awk '{print $1}');
entry=$(echo "$table" | awk '{print $2}');
source "$run_path/src/main_functions"
amo_variables
amo_variables__licenses
if [ "$license__amo_full_name" == "BSD License" ]; then license__fsd_short_name="BSD 2Clause";
elif [ "$license__amo_full_name" == "GNU General Public License, version 3.0" ]; then license__fsd_short_name="GPLv3";
elif [ "$license__amo_full_name" == "GNU General Public License, version 2.0" ]; then license__fsd_short_name="GPLv2";
elif [ "$license__amo_full_name" == "GNU Lesser General Public License, version 3.0" ]; then license__fsd_short_name="LGPLv3";
elif [ "$license__amo_full_name" == "GNU Lesser General Public License, version 2.1" ]; then license__fsd_short_name="LGPLv2.1";
elif [ "$license__amo_full_name" == "MIT/X11 License" ]; then license__fsd_short_name="X11";
elif [ "$license__amo_full_name" == "Mozilla Public License, version 2.0" ]; then license__fsd_short_name="MPLv2.0";
elif [ "$license__amo_full_name" == "Mozilla Public License Version 1.1" ]; then license__fsd_short_name="MPLv1.1";
fi
# Start localization code
source "$run_path/src/main_functions"
locale_description="summary"; do-locale; short_description=$(echo "$summary" | format_description)
locale_description="description"; do-locale; full_description=$(echo "$description" | format_description)
locale_description="homepage"; do-locale
locale_description="support_url"; do-locale
# End localization code
# The homepage field is mandatory so let's remove "null" from it because we don't need to evaluat it
license_copyright=$(jq -r .results[$entry].authors[].name "$file" );
bayesian_average=$(jq .results[$entry].ratings.bayesian_average "$file");
bayesian_average__simple=$(printf "%.1f" "${bayesian_average//./,}");
is_featured=$(jq .results[$entry].is_featured "$file");
last_review_date=$(date +"%Y/%m/%d");
last_review_by="$mediawikibot__bot_password__Username";
submitted_by="$mediawikibot__bot_password__Username";
if [[ "$(jq .results[$entry].current_version.compatibility.seamonkey "$file")" != "null" ]]; then
set_seamonkey="Iceape,";
fi
if [[ "$(jq .results[$entry].current_version.compatibility.firefox "$file")" != "null" ]]; then
set_icecat="IceCat,";
fi
# if [[ "$(jq .results[$entry].current_version.compatibility.android $file)" != "null" ]] || [[ "$(jq .results[$entry].current_version.compatibility.mobile $file)" != "null" ]]; then
# set_icecatmobile="IceCatMobile,";
# fi
if [[ "$(jq .results[$entry].current_version.compatibility.thunderbird "$file")" != "null" ]]; then
set_thunderbird="Icedove,";
fi
# Do not list IceCatMobile
extension_of=$(echo "$set_seamonkey$set_icecat$set_thunderbird" | sed "s|,$||;");
github_true=$(echo "$homepage" | grep "github.com") ||: # ok if grep fails
if [[ $github_true != "" ]]; then
# Always use https, and remove anchors
homepage__for__vcs_checkout_command="https://github.com$(echo "$github_true" | sed "s|https://github.com||; s|http://github.com||; s|#|\\n|;" | head -n 1)";
# Remove trailing slash
homepage__for__vcs_checkout_command="${homepage__for__vcs_checkout_command%/}"
vcs_checkout_command="git clone $homepage__for__vcs_checkout_command.git";
fi
if [ "$name" == "GNU LibreJS" ]; then
is_gnu="Yes";
else
is_gnu="No";
fi
support_url=$(jq .results[$entry].support_url "$file" | sed "s|en-US|en_US|;" | jq -r .en_US);
last_updated=$(jq -r .results[$entry].last_updated $file | sed "s|T|\n|" | head -n 1 | sed "s|-|/|g");
# List JSON structure: cat json/$file | js '.'
# XML value "homepage" is not always set in AMO API, but the XML require "Homepage URL" to be set: Therfore we use the AMO page itself in Homepage URL to complete the build of the repo automatically.
echo "{{Entry" > "$run_path/build/wiki/$slug.wiki"
# Dash have to be removed in jq 1.3: https://github.com/stedolan/jq/issues/341
# Avoid specific versions since it's not compatible with all IceCat versions:
# |Version download=https://addons.mozilla.org/firefox/downloads/latest/$id/addon-$version_id-latest.xpi
# |Version identifier=$version
# |Version date=$version_date
# Do add these fields since we refer to the download page in the `|Version download` field that lists compatible versions
# |Version identifier=52.6.0
# |Version date=2018/02/26
# |Version status=stable
echo "|Name=$name
|Short description=$short_description
|Full description=$full_description
|Homepage URL=$homepage
|Extension of=$extension_of
|VCS checkout command=$vcs_checkout_command
|Documentation note=Extra data (https://addons.mozilla.org/api/v$api_version/addons/addon/$slug/):
* Users: $average_daily_users
* Rating: $bayesian_average__simple
* Updated: $last_updated
* Featured: $is_featured
|Version download=https://addons.mozilla.org/en-US/firefox/addon/$slug/versions/
|Last review by=$last_review_by
|Last review date=$last_review_date
|Submitted by=$submitted_by
|Submitted date=
|Is GNU=$is_gnu
}}" >> "$run_path/build/wiki/$slug.wiki"
# https://addons.mozilla.org/api/v3/addons/addon/noscript/versions/1910123/
echo "{{Project license
|License=$license__fsd_short_name
|License copyright=$license_copyright
|License note=\"License: $license__amo_full_name\" listed
at https://addons.mozilla.org/en-US/firefox/addon/adblock-plus/
}}" >> "$run_path/build/wiki/$slug.wiki"
if [ "$support_url" != "null" ];
then
echo "{{Resource
|Resource audience=Users
|Resource kind=Support
|Resource URL=$support_url
}}" >> "$run_path/build/wiki/$slug.wiki"
fi
if [ "$minimum_average_daily_users" == "100000" ]; then
echo "|-
| [[$slug|$name]]
| $short_description
| [[License:$license__fsd_short_name|$license__fsd_short_name]]
| $average_daily_users
| $bayesian_average__simple
| $last_updated
| $is_featured" >> "$run_path/build/IceCat WebExtensions - Most Users (proposed).wiki"
fi
fi
if ! $debug; then echo "foo"; fi # for pv
done < "$output_file_2" #| pv__progress
if [ "$minimum_average_daily_users" == "100000" ]; then
echo "|}" >> "$run_path/build/IceCat WebExtensions - Most Users (proposed).wiki"
fi
|