diff options
Diffstat (limited to 'subprojects/freeamo/src/main_functions')
-rw-r--r-- | subprojects/freeamo/src/main_functions | 184 |
1 files changed, 134 insertions, 50 deletions
diff --git a/subprojects/freeamo/src/main_functions b/subprojects/freeamo/src/main_functions index a96ada3..7a66cff 100644 --- a/subprojects/freeamo/src/main_functions +++ b/subprojects/freeamo/src/main_functions @@ -15,6 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +function latest_debranded_trisquel_version { + + # All debranded programs starts with "i" so all of them are in Trisquels "/i/" directory + wget -qO- "http://archive.trisquel.info/trisquel/pool/main/i/$debranded_package/?C=N;O=D" | sed "s|\"|\\n|g; s|-|\\n|g" | grep "$debranded_package"_ | head -n 1 | sed "s|"$debranded_package"_||" + +} + function check_files { if [ ! -f "$run_path/FreeAMO-$check_type" ]; then @@ -26,7 +33,7 @@ function check_files { # Make sure all links are using SSL - if grep -q "http://addons.mozilla.org/" $run_path/FreeAMO-$check_type; then + if grep -q "http://addons.mozilla.org/" "$run_path/FreeAMO-$check_type"; then echo "Change http://addons.mozilla.org/ to https://addons.mozilla.org/ (https)." echo "Exiting" && exit @@ -52,22 +59,82 @@ function line_status { } +# Begin locale code + +function locale_description { + + tmp__enUS=$(jq ".results[$entry].$locale_description" "$file" | sed "s|-||;" | jq .enUS | sed "s|^\"||; s|\"$||;" ) + tmp__enGB=$(jq ".results[$entry].$locale_description" "$file" | sed "s|-||;" | jq .enGB | sed "s|^\"||; s|\"$||;" ) + if [ "$tmp__enUS" != "null" ]; then + + if [ "$locale_description" == "name" ]; then + + name="$tmp__enUS"; + + elif [ "$locale_description" == "summary" ]; then + + summary="$tmp__enUS"; + + elif [ "$locale_description" == "description" ]; then + + description="$tmp__enUS"; + + fi + + + elif [ "$tmp__enGB" != "null" ]; then + + if [ "$locale_description" == "name" ]; then + + name="$tmp__enGB"; + + elif [ "$locale_description" == "summary" ]; then + + summary="$tmp__enGB"; + + elif [ "$locale_description" == "description" ]; then + + description="$tmp__enGB"; + + fi + + else + + tmp=$(jq ".results[$entry].$locale_description[]" "$file" | sed "s|-||;" | jq . | sed "s|^\"||; s|\"$||;"); # Use the first avalible summary if English is not avaliable + + if [ "$locale_description" == "name" ]; then + + name="$tmp"; + + elif [ "$locale_description" == "summary" ]; then + + summary="$tmp"; + + elif [ "$locale_description" == "description" ]; then + + description="$tmp"; + + fi + + + fi + +} + +# End locale code + + function amo_variables() { id="$(jq ".results[$entry].id" "$file")"; average_daily_users="$(jq ".results[$entry].average_daily_users" "$file")"; has_eula="$(jq ".results[$entry].has_eula" "$file")"; slug="$(jq ".results[$entry].slug" "$file" | sed "s|^\"||; s|\"$||;")"; current_version__id=$(jq ".results[$entry].current_version.id" "$file"); - - # Names - name__enUS=$(jq ".results[$entry].name" "$file" | sed "s|-||;" | jq .enUS | sed "s|^\"||; s|\"$||;" ) - name__enGB=$(jq ".results[$entry].name" "$file" | sed "s|-||;" | jq .enGB | sed "s|^\"||; s|\"$||;" ) - if [ "$name__enUS" != "null" ]; then name="$name__enUS"; - elif [ "$name__enGB" != "null" ]; then name="$name__enGB"; - else name=$(jq ".results[$entry].name[]" "$file" | sed "s|-||;" | jq . | sed "s|^\"||; s|\"$||;"); # Use the first avalible name if English is not avaliable - fi - + source "$run_path/src/main_functions" + locale_description="name" + locale_description + if jq .results[$entry].current_version.files[0].permissions "$file" | grep -q "nativeMessaging"; then nativeMessaging__pass=false; @@ -102,60 +169,77 @@ function essential_addon { #function hard_to_evaluate_addon { - # curl "https://addons.mozilla.org/api/v3/addons/addon/nemid-nøglefilsprogram/" | jq .current_version.files[0].permissions | grep "nativeMessaging - +# curl "https://addons.mozilla.org/api/v3/addons/addon/nemid-nøglefilsprogram/" | jq .current_version.files[0].permissions | grep "nativeMessaging + + +# API data: Add software dependencies - https://github.com/mozilla/addons-server/issues/8668 +# The API should be fixed. there are to many add-ons to keep track on if they have or not have software dependencies. + +# Old solution: - # API data: Add software dependencies - https://github.com/mozilla/addons-server/issues/8668 - # The API should be fixed. there are to many add-ons to keep track on if they have or not have software dependencies. - - # Old solution: - - # 1: Add this to FreeAMO-dependencies: - #belgium-eid eid-mw - - # 2: Uncomment this code: - # depends_on_external_program=false; - # while IFS= read -r dependencies; do - # - # dependency_slug=$(echo $dependencies | awk '{print $1}'); - # dependency=$(echo "$dependencies" | cut -f 2); - # - # if [ "$dependency_slug" == "$slug" ]; then - # - # depends_on_external_program=true; - # - # fi - # - # done < $run_path/FreeAMO-dependencies +# 1: Add this to FreeAMO-dependencies: +#belgium-eid eid-mw + +# 2: Uncomment this code: +# depends_on_external_program=false; +# while IFS= read -r dependencies; do +# +# dependency_slug=$(echo $dependencies | awk '{print $1}'); +# dependency=$(echo "$dependencies" | cut -f 2); +# +# if [ "$dependency_slug" == "$slug" ]; then +# +# depends_on_external_program=true; +# +# fi +# +# done < $run_path/FreeAMO-dependencies #} -function progress { - - (>&2 echo -en "\r"; pv --progress --line-mode --size $pv__size --eta --timer) > /dev/null - +function pv__progress { + + if [ ! "$pv__discard" = true ]; then + + (pv --progress --line-mode --size "$pv__size" --timer) > /dev/null + + fi + } -function html_to_mediawiki { +function format_description__mixed_html_to_mediawiki { sed " # Remove Mozilla tracking links -s|https://outgoing.prod.mozaws.net/v1/.\{65\}||g; s|%3A|:|g; s|%23|#|g +s|https://outgoing.prod.mozaws.net/v1/.\\{65\\}||g; s|%3A|:|g; s|%23|#|g -# Fix general links -s|<a rel=\\\\\\\"nofollow\\\\\\\" href=\\\\\\\"|[|g -s|\\\\\\\">| |g -s|</a>|]|g +# Remove reduntant backslashes. Pandoc will convert quotes regardless. +s|\\\\\\\"|\\\"|g -# Fix line breaks -s|\\\\n|\\n|g -# Fix quotes -s|\\\\\\\"|\\\"|g +" + +} + +function format_description__after_pandoc { + + sed " + +### Fix formatting that cannot be fixed by Pandoc since it's not HTML + +# Fix line breaks. +s|\\\\n|\\n|g -# Fix bullets, many developers failed to use <li> needed to make line break -s|\\n- |\\n* |g +# Remove \t +s|\\\\t||g " + # Change local links to external links + +} + +function format_description { + + format_description__mixed_html_to_mediawiki | pandoc -f html -t mediawiki | format_description__after_pandoc } |