Skip to content

Commit 1cd7e66

Browse files
authored
Add and use am2pla-site script here (#44)
* Add am2pla-site from AM * Update lister.yml - run "am2pla-site" from this repo
1 parent bad5186 commit 1cd7e66

File tree

2 files changed

+319
-2
lines changed

2 files changed

+319
-2
lines changed

.github/workflows/lister.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ jobs:
2323

2424
- name: "Run lister"
2525
run: |
26-
wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/tools/am2pla-site && chmod a+x ./am2pla-site || exit 1
2726
sed -i 's/^cd "$(xdg-user-dir DESKTOP)"/#cd "$(xdg-user-dir DESKTOP)"/g' ./am2pla-site
2827
./am2pla-site
29-
rm -f ./am2pla-site
3028
3129
- name: "Push to Source"
3230
run: |

am2pla-site

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

0 commit comments

Comments
 (0)