am2pla-site 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. #!/usr/bin/env bash
  2. # This is a script I use to create and update the application list on https://portable-linux-apps.github.io/
  3. # Once created, the page will appear like this: https://portable-linux-apps.github.io/apps.html
  4. # First of all, we need to create a file containing all the arguments that this script must read
  5. AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
  6. arch="x86_64"
  7. # ENTER THE DESKTOP DIRECTORY
  8. cd "$(xdg-user-dir DESKTOP)" || exit 1
  9. # GET THE NAMES OF ALL APPLICATION
  10. if [ -f "$HOME"/.local/share/AM/"$arch"-apps ]; then
  11. cp "$HOME"/.local/share/AM/"$arch"-apps "$arch"-apps && echo -e "$(cat ./"$arch"-apps | awk -v FS="(◆ | : )" '{print $2}')" >> args
  12. elif [ -f ./"$arch"-apps ]; then
  13. echo -e "$(cat ./"$arch"-apps | awk -v FS="(◆ | : )" '{print $2}')" >> args
  14. else
  15. curl -Ls "$AMREPO"/programs/"$arch"-apps > "$arch"-apps && echo -e "$(cat ./"$arch"-apps | awk -v FS="(◆ | : )" '{print $2}')" >> args
  16. fi
  17. # GET THE EXACT NUMBER OF AVAILABLE APPS
  18. ARGS=$(cat ./args)
  19. APPS_NUMBER=$(grep -v "ffwa-\|\"kdegames\"\|\"kdeutils\"\|\"node\"\|\"platform-tools\"" "$arch"-apps | grep -e "$" -c)
  20. ITEMS_NUMBER=$(grep "ffwa-\|\"kdegames\"\|\"kdeutils\"\|\"node\"\|\"platform-tools\"" "$arch"-apps | grep -e "$" -c)
  21. CATEGORIES="android audio \
  22. comic command-line communication \
  23. disk \
  24. education \
  25. file-manager finance \
  26. game gnome graphic \
  27. internet \
  28. kde \
  29. office \
  30. password \
  31. steam system-monitor \
  32. video \
  33. web-app web-browser wine"
  34. ##########################################################
  35. # UPDATE THE JSON FILE FOR FURTER ELECTRON-BASED FRONTENDS
  36. ##########################################################
  37. function _update_json() {
  38. echo "[" > apps.json
  39. for arg in $ARGS; do
  40. description=$(grep "◆ $arg :" "$arch"-apps | sed 's/"/\\"/g; s/^.*: //')
  41. printf " {\n \"packageName\": \"%b\",\n \"description\": \"%b..\",\n \"icon\": \"https://portable-linux-apps.github.io/icons/%b.png\"\n },\n" "$arg" "$description" "$arg" >> apps.json
  42. done
  43. sed -i '$s/,$//' apps.json
  44. echo "]" >> apps.json
  45. }
  46. _update_json
  47. ################################################
  48. # COMMON FUNCTIONS NEEDED TO COMPILE OTHER PAGES
  49. ################################################
  50. function _home_button {
  51. echo ""
  52. echo "| [Home](index.md) |"
  53. echo "| --- |"
  54. echo ""
  55. }
  56. function _table_head() {
  57. echo "-----------------"
  58. echo ""
  59. echo "*NOTE, the installer scripts in the \"INSTALLER\" column are intended for use via \"AM\", and are therefore dedicated to a system-wide \
  60. installation of applications (in /opt), and all that \"AppMan\" does is convert those scripts for local installation, changing the paths. \
  61. **They are listed here for reading purposes only**!*"
  62. echo ""
  63. echo "*Should you decide to run them manually, the only way to remove the application is to run \
  64. the command \"\`sudo /opt/appname/remove\`\", where \"appname\" is the name of the application directory containing the \"remove\" script. \
  65. Likewise, you can also update applications by running the \"AM-updater\" script in the same directory.*"
  66. echo ""
  67. echo "*The \"AM\" project allow the autonomy of installed apps, regardless of the presence of \"AM\" itself in the system. However, it is strongly \
  68. recommended to use \"AM\" and \"AppMan\" to take full advantage of all the benefits you could get from an application installed in this way.*"
  69. echo ""
  70. echo "*If you are here just to download apps manually, click on the program name and check the URL(s) on the application page. This site does not \
  71. provide direct links, for security reasons, but it does provide the exact sources and references where you can find them!*"
  72. echo ""
  73. echo "*Transparency and credibility are the focus of this catalog. Happy exploring!*"
  74. echo ""
  75. echo "-----------------"
  76. echo ""
  77. echo "| ICON | PACKAGE NAME | DESCRIPTION | INSTALLER |"
  78. echo "| --- | --- | --- | --- |"
  79. }
  80. function _categories_buttons() {
  81. echo ""
  82. echo "#### *Categories*"
  83. echo ""
  84. #- ***[SAMPLE](https://portable-linux-apps.github.io/SAMPLE.html)*** \
  85. echo "***[AppImages](appimages.md)*** \
  86. $(for c in $CATEGORIES; do printf " - ***[$c]($c.md)***"; done)"
  87. echo ""
  88. }
  89. function _categories_buttons_on_footer() {
  90. echo ""
  91. echo "| [Back to Home](index.md) | [Back to Applications](apps.md)"
  92. echo "| --- | --- |"
  93. echo ""
  94. }
  95. function _back_to_apps_button() {
  96. echo ""
  97. echo "| [Back to Applications](apps.md) |"
  98. echo "| --- |"
  99. echo ""
  100. }
  101. function _footer_up() {
  102. echo ""
  103. echo ""
  104. echo "---"
  105. echo ""
  106. echo "You can improve these pages via a [pull request](https://github.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/pulls) \
  107. to this site's [GitHub repository](https://github.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io), \
  108. or report any problems related to the installation scripts in the '[issue](https://github.com/ivan-hc/AM/issues)' \
  109. section of the main database, at [https://github.com/ivan-hc/AM](https://github.com/ivan-hc/AM)."
  110. echo ""
  111. echo "***PORTABLE-LINUX-APPS.github.io is my gift to the Linux community and was made with love for GNU/Linux and the Open Source philosophy.***"
  112. echo ""
  113. echo "---"
  114. }
  115. function _footer_down() {
  116. echo "--------"
  117. echo ""
  118. echo "# Contacts"
  119. echo "- **Ivan-HC** *on* [**GitHub**](https://github.com/ivan-hc)"
  120. echo "- **AM-Ivan** *on* [**Reddit**](https://www.reddit.com/u/am-ivan)"
  121. echo ""
  122. echo "###### *You can support me and my work on [**ko-fi.com**](https://ko-fi.com/IvanAlexHC) and \
  123. [**PayPal.me**](https://paypal.me/IvanAlexHC). Thank you!*"
  124. echo ""
  125. echo "--------"
  126. echo ""
  127. echo "*© 2020-present Ivan Alessandro Sala aka '"'Ivan-HC'"'* - I'm here just for fun!"
  128. echo ""
  129. echo ""
  130. }
  131. function _footer_apps() {
  132. _footer_up
  133. _home_button
  134. _footer_down
  135. }
  136. function _footer_categories() {
  137. _footer_up
  138. _categories_buttons_on_footer
  139. _footer_down
  140. }
  141. ###############################
  142. # COMPILE THE APPLICATIONS LIST
  143. ###############################
  144. function _applications_list_header {
  145. echo "# APPLICATIONS" > apps.md
  146. _home_button >> apps.md
  147. echo "#### Here are listed all **$APPS_NUMBER** unique applications, AppImage packages and command line utilities managed by [AM](https://github.com/ivan-hc/AM) \
  148. and [AppMan](https://github.com/ivan-hc/AppMan) for the x86_64 architecture, plus **$ITEMS_NUMBER** more entries and items to help you install apps more easily." >> apps.md
  149. echo "" >> apps.md
  150. echo "*Use your browser's built-in search tool to easily navigate to this page or use the tags below.*" >> apps.md
  151. echo "" >> apps.md
  152. _categories_buttons >> apps.md
  153. _table_head >> apps.md
  154. }
  155. function _applications_list_body() {
  156. for arg in $ARGS; do
  157. description=$(grep "◆ $arg :" "$arch"-apps | sed 's/^.*: //; s/ *$//')
  158. echo "| <img loading=\"lazy\" src=\"icons/$arg.png\" width=\"48\" height=\"48\"> | [***$arg***](apps/$arg.md) | *$description*..[ *read more* ](apps/$arg.md)*!* | [*blob*](https://github.com/ivan-hc/AM/blob/main/programs/$arch/$arg) **/** [*raw*](https://raw.githubusercontent.com/ivan-hc/AM/main/programs/$arch/$arg) |" >> body.txt &
  159. done
  160. wait
  161. sort -u ./body.txt >> apps.md
  162. }
  163. _applications_list_header
  164. _applications_list_body
  165. _footer_apps >> apps.md
  166. ########################
  167. # COMPILE APPIMAGES PAGE
  168. ########################
  169. function _appimages_listing() {
  170. if [ -f "$HOME"/.local/share/AM/"$arch"-appimages ]; then
  171. APPIMAGES_LIST_AM=$(cat "$HOME"/.local/share/AM/"$arch"-appimages | awk -v FS="(◆ | : )" '{print $2}')
  172. elif [ -f ./"$arch"-appimages ]; then
  173. APPIMAGES_LIST_AM=$(cat ./"$arch"-appimages | awk -v FS="(◆ | : )" '{print $2}')
  174. else
  175. APPIMAGES_LIST_AM=$(curl -Ls https://raw.githubusercontent.com/ivan-hc/AM/main/programs/x86_64-appimages)
  176. fi
  177. [ -z "$APPIMAGES_LIST_AM" ] && exit 1
  178. echo "$APPIMAGES_LIST_AM" | awk -v FS="(◆ | : )" '{print $2}' > args
  179. ARGS=$(cat ./args)
  180. APPIMAGES_NUMBER=$(cat ./args | wc -l)
  181. }
  182. function _appimages_list_header {
  183. echo "# APPIMAGES" > appimages.md
  184. _home_button >> appimages.md
  185. echo "#### Here are listed the **$APPIMAGES_NUMBER** unique Appimages managed by [AM](https://github.com/ivan-hc/AM) \
  186. and [AppMan](https://github.com/ivan-hc/AppMan) for the x86_64 architecture." >> appimages.md
  187. echo "" >> appimages.md
  188. echo "*Use your browser's built-in search tool to easily navigate to this page or use the tags below.*" >> appimages.md
  189. echo "" >> appimages.md
  190. _back_to_apps_button >> appimages.md
  191. _categories_buttons >> appimages.md
  192. _table_head >> appimages.md
  193. }
  194. function _appimages_list_body() {
  195. for arg in $ARGS; do
  196. grep "apps/$arg.md" ./body.txt >> appimages.md
  197. done
  198. }
  199. _appimages_listing
  200. _appimages_list_header
  201. _appimages_list_body
  202. _footer_categories >> appimages.md
  203. ######################################
  204. # COMPILE THE MAIN PAGE OF THE WEBSITE
  205. ######################################
  206. ST_APPS_NUMBER=$(($APPS_NUMBER-$APPIMAGES_NUMBER))
  207. function _compile_the_homepage() {
  208. if [ -f ./index.md ]; then
  209. cat ./index.md > index.old
  210. else
  211. curl -Ls https://raw.githubusercontent.com/Portable-Linux-Apps/Portable-Linux-Apps.github.io/main/index.md > index.old
  212. fi
  213. sed -n '1,10p' ./index.old > ./index.md
  214. echo "#### *This site lists **$APPS_NUMBER** unique apps (**$APPIMAGES_NUMBER** Appimage packages and **$ST_APPS_NUMBER** standalone/portable programs), plus **$ITEMS_NUMBER** items.*" >> ./index.md
  215. sed -n '12,19p' ./index.old >> ./index.md
  216. _categories_buttons >> ./index.md
  217. sed -n '25,20000p' ./index.old >> ./index.md
  218. }
  219. _compile_the_homepage
  220. ##################
  221. # OTHER CATEGORIES
  222. ##################
  223. function _category_list_header {
  224. echo "# $(echo "$category" | tr a-z A-Z)" > "$category".md
  225. _home_button >> "$category".md
  226. echo "#### Here are listed **$APPS_NUMBER** programs and **$ITEMS_NUMBER** items for this category and managed by [AM](https://github.com/ivan-hc/AM) \
  227. and [AppMan](https://github.com/ivan-hc/AppMan) for the x86_64 architecture." >> "$category".md
  228. echo "" >> "$category".md
  229. echo "*Use your browser's built-in search tool to easily navigate to this page or use the tags below.*" >> "$category".md
  230. echo "" >> "$category".md
  231. _back_to_apps_button >> "$category".md
  232. _categories_buttons >> "$category".md
  233. _table_head >> "$category".md
  234. }
  235. function _category_list_body() {
  236. for arg in $ARGS; do
  237. grep "apps/"$arg".md" ./body.txt >> $category.md
  238. done
  239. }
  240. for category in $CATEGORIES; do
  241. if [ "$category" = android ]; then
  242. grep -i "$category\| adb \|fastboot\|phone\|platform-tools" ./"$arch"-apps >> "$arch-$category"
  243. elif [ "$category" = audio ]; then
  244. grep -i "$category\|music\|midi\|mp3\|sound" ./"$arch"-apps >> "$arch-$category"
  245. elif [ "$category" = comic ]; then
  246. grep -i "$category\|manga\|epub\|anime" ./"$arch"-apps >> "$arch-$category"
  247. elif [ "$category" = command-line ]; then
  248. grep -i "$category\|command line\| cli \|terminal\|fastboot\| npm \| bash \| shell \| dash \| zsh " ./"$arch"-apps >> "$arch-$category"
  249. elif [ "$category" = communication ]; then
  250. grep -i "$category\|voip\|facebook\|messenger\|whatsapp\|mastodon\|skype\|chat\|social network\|zoom\|conferenc\|discord\|email" ./"$arch"-apps >> "$arch-$category"
  251. elif [ "$category" = disk ]; then
  252. grep -i "$category\|partition\|usb" ./"$arch"-apps >> "$arch-$category"
  253. elif [ "$category" = education ]; then
  254. grep -i "$category\| edu\|science\|learn\|study\|teach\|translat\|geo\|child\| book\|ebook\|space simulator\|planet\|astronom" ./"$arch"-apps | grep -vi "game\|manga\|anime" >> "$arch-$category"
  255. elif [ "$category" = file-manager ]; then
  256. grep -i "$category\|file manager\|file browse\|browse.*file\|file explore" ./"$arch"-apps >> "$arch-$category"
  257. elif [ "$category" = finance ]; then
  258. grep -i "$category\|wallet\|money\|economy\|economic" ./"$arch"-apps >> "$arch-$category"
  259. elif [ "$category" = game ]; then
  260. grep -i "$category\|arcade\|steam\|wine\|strateg\|solitaire\|poker\|chess\|puzzle\|pinball\|adventure\|playstation\|xbox\|nintendo\|minecraft\|doom" ./"$arch"-apps >> "$arch-$category"
  261. elif [ "$category" = graphic ]; then
  262. grep -i "$category\|picture\|screensh\|gimp\|photo\|svg\|png\|autocad\|blender\|modeling\|paint\|pixel\|wallpaper" ./"$arch"-apps >> "$arch-$category"
  263. elif [ "$category" = internet ]; then
  264. grep -i "$category\|web browser\|browser web\|firefox\|chrome\|youtube\|torrent\|p2p\|chat\|whatsapp\|mastodon\|telegram\|skype\|email" ./"$arch"-apps >> "$arch-$category"
  265. elif [ "$category" = office ]; then
  266. grep -i "$category\|document\|book\|pdf\|docx\|reader\|spreadsheet\| word \| excel " ./"$arch"-apps >> "$arch-$category"
  267. elif [ "$category" = password ]; then
  268. grep -i "$category" ./"$arch"-apps >> "$arch-$category"
  269. elif [ "$category" = system-monitor ]; then
  270. grep -i "$category\|system monitor\|task manager\|system resource" ./"$arch"-apps >> "$arch-$category"
  271. elif [ "$category" = video ]; then
  272. grep -i "$category\|stream\|media player\|film\|movie\|netflix\|youtube\|iptv" ./"$arch"-apps >> "$arch-$category"
  273. elif [ "$category" = web-app ]; then
  274. grep -i "$category\|webapp\|web app\|ffwa" ./"$arch"-apps >> "$arch-$category"
  275. elif [ "$category" = web-browser ]; then
  276. grep -i "$category\|web browser\|browser web\|browser.*web\|browser.*chrome\|brave.*browser\|chrome.*browser\|chromium.*browser\|firefox.*web browser\|vivaldi\|thorium\|mercury\|librewolf" ./"$arch"-apps >> "$arch-$category"
  277. else
  278. grep -i "$category" ./"$arch"-apps >> "$arch-$category"
  279. fi
  280. echo -e "$(cat ./"$arch-$category" | awk -v FS="(◆ | : )" '{print $2}')" > args
  281. ARGS=$(cat ./args)
  282. APPS_NUMBER=$(grep -v "ffwa-\|\"kdegames\"\|\"kdeutils\"\|\"node\"\|\"platform-tools\"" "$arch-$category" | grep -e "$" -c)
  283. ITEMS_NUMBER=$(grep "ffwa-\|\"kdegames\"\|\"kdeutils\"\|\"node\"\|\"platform-tools\"" "$arch-$category" | grep -e "$" -c)
  284. _category_list_header
  285. _category_list_body
  286. _footer_categories >> "$category".md
  287. rm -f ./"$arch-$category"
  288. done
  289. ######################
  290. # END OF ALL PROCESSES
  291. ######################
  292. rm ./args ./index.old ./"$arch"-apps ./body.txt