Skip to content

Commit a492015

Browse files
authored
Merge pull request #5 from Xpirix/frontend_update
Frontend update
2 parents f0506f4 + e4e8739 commit a492015

File tree

2,294 files changed

+51703
-21540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,294 files changed

+51703
-21540
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
run: cp .env.template .env
5252

5353

54+
- name: Run docker-compose build
55+
run: docker compose build
56+
5457
- name: Run the containers
5558
run: docker compose up -d db devweb
5659

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ qgis-app/api/tests/*/
5555
qgis-app/whoosh_index/
5656
docker-compose.override.yml
5757
.env
58+
59+
# Webpack
60+
node_modules
61+
qgis-app/static/bundles
62+
qgis-app/package-lock.json
63+
qgis-app/webpack-stats.json
64+
65+
# Sustaining members template
66+
qgis-app/templates/flatpages/sustaining_members.html

INSTALL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Development Environment
44

5-
- Clone git repo `git clone https://github.com/qgis/QGID-Plugins-Website.git`
5+
- Clone git repo `git clone https://github.com/qgis/QGIS-Plugins-Website.git`
66
- Run `$ pwd` in order to get your current directory
7-
- Path to your repo should be `<your current directory>/QGID-Plugins-Website `
8-
- Go to dockerize directory `cd QGID-Plugins-Website/dockerize`
7+
- Path to your repo should be `<your current directory>/QGIS-Plugins-Website `
8+
- Go to dockerize directory `cd QGIS-Plugins-Website/dockerize`
99

1010
- Build and spin container
1111
```bash
@@ -65,7 +65,7 @@ pre-commit install --config .pre-commit-config.yaml
6565

6666
### Setting up a remote interpreter in PyCharm
6767

68-
- PyCharm -> Preferences -> Project: QGID-Plugins-Website
68+
- PyCharm -> Preferences -> Project: QGIS-Plugins-Website
6969
- Click on the gear icon next to project interpreter -> add
7070
- SSH Interpreter -> New server configuration
7171
- Host : `localhost`
@@ -116,7 +116,7 @@ Now set these options:
116116
filesystem and the filesystem in the remote (docker) host. Click the ellipsis
117117
and add a run that points to your git checkout on your local host and the
118118
/home/web directory in the docker host. e.g.
119-
* **Local path:** <path to your git repo>/QGID-Plugins-Website/qgis-app
119+
* **Local path:** <path to your git repo>/QGIS-Plugins-Website/qgis-app
120120
* **Remote path:** /home/web/django_project
121121
* click OK to save your run configuration
122122

dockerize/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ exec:
199199
@echo "------------------------------------------------------------------"
200200
@docker compose -p $(PROJECT_ID) $(c)
201201

202+
loadmenu:
203+
@echo
204+
@echo "------------------------------------------------------------------"
205+
@echo "Delete all simplemenu entries and load from fixtures/all_menu.json"
206+
@echo "------------------------------------------------------------------"
207+
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py clear_simplemenu
208+
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py loaddata fixtures/all_menu.json
202209
# ----------------------------------------------------------------------------
203210
# D E V E L O P M E N T C O M M A N D S
204211
# ----------------------------------------------------------------------------
@@ -222,7 +229,7 @@ devweb: db
222229
@echo "------------------------------------------------------------------"
223230
@echo "Running in DEVELOPMENT mode"
224231
@echo "------------------------------------------------------------------"
225-
@docker compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat
232+
@docker compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat webpack
226233

227234
devweb-runserver: devweb
228235
@echo
@@ -236,4 +243,4 @@ dbseed:
236243
@echo "------------------------------------------------------------------"
237244
@echo "Seed db with JSON data from /fixtures/*.json"
238245
@echo "------------------------------------------------------------------"
239-
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py loaddata fixtures/*.json'
246+
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py loaddata fixtures/*.json'

dockerize/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ make devweb-runserver
179179
make dbseed
180180
```
181181

182+
- **loadmenu:** Clear all menu entries and load menu from JSON file at `fixtures/simplemenu.json`.
183+
```sh
184+
make loadmenu
185+
```

dockerize/docker-compose.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services:
5959
- ${QGISPLUGINS_STATIC_VOLUME}:/home/web/static:rw
6060
- ${QGISPLUGINS_MEDIA_VOLUME}:/home/web/media:rw
6161
- celerybeat-schedule:/home/web/celerybeat-schedule:rw
62-
command: uwsgi --ini /uwsgi.conf
62+
command: bash -c "npm install && npm run build && uwsgi --ini /uwsgi.conf"
6363
depends_on:
6464
- db
6565
- rabbitmq
@@ -90,6 +90,19 @@ services:
9090
networks:
9191
internal:
9292

93+
webpack:
94+
container_name: qgis-plugins-webpack
95+
build:
96+
context: ${PWD}/../
97+
dockerfile: dockerize/docker/Dockerfile
98+
target: dev
99+
working_dir: /home/web/django_project
100+
command: npm start
101+
volumes:
102+
- ../qgis-app:/home/web/django_project
103+
- ${QGISPLUGINS_STATIC_VOLUME}:/home/web/static:rw
104+
- ${QGISPLUGINS_MEDIA_VOLUME}:/home/web/media:rw
105+
93106
rabbitmq:
94107
image: rabbitmq:3.7-alpine
95108
hostname: rabbitmq

dockerize/docker/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ ADD dockerize/docker/REQUIREMENTS.txt /REQUIREMENTS.txt
3333

3434
RUN pip install --upgrade pip && pip install -r /REQUIREMENTS.txt
3535

36+
# Install NodeJS and bulma css webpack
37+
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends wget && \
38+
wget --no-check-certificate https://deb.nodesource.com/setup_20.x -O /tmp/node.sh && bash /tmp/node.sh && \
39+
apt-get -qq update && apt-get -qq install -y nodejs build-essential
40+
41+
WORKDIR /home/web/django_project
42+
COPY qgis-app/package.json /home/web/django_project/package.json
43+
RUN npm install -g npm@10.2.1 && npm install -g webpack@5.89.0 && npm install -g webpack-cli@5.1.4 && npm install
44+
3645
RUN mkdir -p /var/log/uwsgi
3746

3847
WORKDIR /home/web/django_project

dockerize/docker/REQUIREMENTS.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ uwsgi~=2.0
5252
freezegun~=1.4
5353

5454
sentry-sdk~=2.2
55+
django-webpack-loader~=3.1
56+
57+
beautifulsoup4~=4.12
58+
setuptools~=75.1

dockerize/production/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev li
1313

1414
ARG BRANCH_TAG=develop
1515
RUN mkdir -p /usr/src; mkdir -p /home/web && \
16-
git clone --depth=1 git://github.com/qgis/QGID-Plugins-Website.git --branch ${BRANCH_TAG} /usr/src/plugins/ && \
16+
git clone --depth=1 git://github.com/qgis/QGIS-Plugins-Website.git --branch ${BRANCH_TAG} /usr/src/plugins/ && \
1717
rm -rf /home/web/django_project && \
1818
ln -s /usr/src/plugins/qgis-app /home/web/django_project
1919

dockerize/scripts/renew-ssl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# 2021-11-12 11:10:00 UTC
1212
# ...etc
1313

14-
#25 11 * * * /bin/bash /home/web/QGID-Plugins-Website/dockerize/scripts/renew_ssl.sh > /tmp/ssl-renewal-logs.txt
14+
#25 11 * * * /bin/bash /home/web/QGIS-Plugins-Website/dockerize/scripts/renew_ssl.sh > /tmp/ssl-renewal-logs.txt
1515

1616

17-
docker compose -f /home/web/QGID-Plugins-Website/dockerize/docker-compose.yml -p qgis-plugins run certbot renew
17+
docker compose -f /home/web/QGIS-Plugins-Website/dockerize/docker-compose.yml -p qgis-plugins run certbot renew

dockerize/sites-enabled/docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ if [ $# -eq 1 ]; then
1919
echo "Run in prod mode"
2020
CONF_FILE=prod.conf
2121
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
22+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
2223
exec nginx -g "daemon off;"
2324
;;
2425
# Production SSL mode, run using uwsgi
2526
[Pp][Rr][Oo][Dd][-][Ss][Ss][Ll])
2627
echo "Run in prod SSL mode"
2728
CONF_FILE=prod-ssl.conf
2829
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
30+
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
2931
exec nginx -g "daemon off;"
3032
;;
3133
esac

dockerize/sites-enabled/prod-ssl.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ server {
9696
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzzle|harvest|HMView|HomePageBot|HTTP\:\:Lite|HubSpot|icarus6|IDBot|id\-search|IlseBot|Image\ Stripper|Image\ Sucker|Indigonet|Indy\ Library|integromedb|InterGET|InternetSeer\.com|Internet\ Ninja|IRLbot|ISC\ Systems\ iRc\ Search\ 2\.1|jakarta|JetCar|JobdiggerSpider|JOC\ Web\ Spider|Jooblebot|kanagawa|KINGSpider|kmccrew|larbin|LeechFTP|libwww|Lingewoud|LinkChecker|linkdexbot|LinksCrawler|LinksManager\.com_bot|linkwalker|LinqiaRSSBot|LivelapBot|ltx71|LubbersBot|lwp\-trivial|Mail.RU_Bot|masscan|Mass\ Downloader|maverick|Maxthon$|Mediatoolkitbot|MegaIndex|MegaIndex|megaindex|MFC_Tear_Sample|Microsoft\ URL\ Control|microsoft\.url|MIDown\ tool|miner|Missigua\ Locator|Mister\ PiX|mj12bot|Mozilla.*Indy|Mozilla.*NEWT|MSFrontPage|msnbot|Navroad|NearSite|NetAnts|netEstate|NetSpider|NetZIP|Net\ Vampire|NextGenSearchBot|nutch|Octopus|Offline\ Explorer|Offline\ Navigator|OpenindexSpider|OpenWebSpider|OrangeBot|Owlin|PageGrabber|PagesInventory|panopta|panscient\.com|Papa\ Foto|pavuk|pcBrowser|PECL\:\:HTTP|PeoplePal|Photon|PHPCrawl|planetwork|PleaseCrawl|PNAMAIN.EXE|PodcastPartyBot|prijsbest|proximic|psbot|purebot|pycurl|QuerySeekerSpider|R6_CommentReader|R6_FeedFetcher|RealDownload|ReGet|Riddler|Rippers\ 0|rogerbot|RSSingBot|rv\:1.9.1|RyzeCrawler|SafeSearch|SBIder|Screaming|search.goo.ne.jp|SearchmetricsBot|search_robot|SemrushBot|Semrush|SentiBot|SEOkicks|SeznamBot|ShowyouBot|SightupBot|SISTRIX|sitecheck\.internetseer\.com|siteexplorer.info|SiteSnagger|skygrid|Slurp|SmartDownload|Snoopy|Sogou|Sosospider|spaumbot|Steeler|sucker|SuperBot|Superfeedr|SuperHTTP|SurdotlyBot|Surfbot|tAkeOut|Teleport\ Pro|TinEye-bot|TinEye|Toata\ dragostea\ mea\ pentru\ diavola|Toplistbot|trendictionbot|TurnitinBot|turnit|URI\:\:Fetch|Vagabondo|Vagabondo|vikspider|VoidEYE|VoilaBot|WBSearchBot|webalta|WebAuto|WebBandit|WebCollage|WebCopier|WebFetch|WebGo\ IS|WebLeacher|WebReaper|WebSauger|Website\ eXtractor|Website\ Quester|WebStripper|WebWhacker|WebZIP|Web\ Image\ Collector|Web\ Sucker|Wells\ Search\ II|WEP\ Search|WeSEE|Widow|WinInet|woobot|woopingbot|worldwebheritage.org|Wotbox|WPScan|WWWOFFLE|WWW\-Mechanize|Xaldon\ WebSpider|XoviBot|yacybot|Yahoo|YandexBot|Yandex|YisouSpider|zermelo|Zeus|zh-CN|ZmEu|ZumBot|ZyBorg) ) {
9797
return 403;
9898
}
99+
100+
# Redirect planet and hub resources to the new location
101+
include redirections.conf;
99102
}
100103

101104
location /metabase/ {
@@ -220,6 +223,9 @@ server {
220223
return 403;
221224
}
222225

226+
# Redirect planet and hub resources to the new location
227+
include redirections.conf;
228+
223229
}
224230

225231

dockerize/sites-enabled/prod.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ server {
9494
return 403;
9595
}
9696

97+
# Redirect planet and hub resources to the new location
98+
include redirections.conf;
99+
97100
}
98101

99102

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rewrite ^/planet$ https://planet.qgis.org permanent;
2+
rewrite ^/styles(.*)$ https://hub.qgis.org/styles$1 permanent;
3+
rewrite ^/geopackages(.*)$ https://hub.qgis.org/geopackages$1 permanent;
4+
rewrite ^/models(.*)$ https://hub.qgis.org/models$1 permanent;
5+
rewrite ^/wavefronts(.*)$ https://hub.qgis.org/wavefronts$1 permanent;
6+
rewrite ^/layerdefinitions(.*)$ https://hub.qgis.org/layerdefinitions$1 permanent;

qgis-app/custom_haystack_urls.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,19 @@ def build_form(self, form_kwargs=None):
2828

2929
def get_results(self):
3030
"""
31-
Fetches the results
31+
Fetches the search results and sorts them in descending order based on the 'downloads' attribute.
32+
If the 'downloads' attribute is not present or the object is None, it defaults to 0.
3233
"""
33-
return self.form.searchqueryset
34+
results = self.form.searchqueryset
35+
sort_by = 'downloads'
36+
results = sorted(
37+
results,
38+
key=lambda x: int(
39+
getattr(x.object, sort_by)
40+
) if x.object is not None else 0,
41+
reverse=True # Reverse the sort order
42+
)
43+
return results
3444

3545

3646
urlpatterns = [

qgis-app/docs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from django.shortcuts import render
2+
from django.utils.translation import gettext_lazy as _
3+
4+
5+
6+
def docs_publish(request):
7+
"""
8+
Renders the docs_publish page
9+
"""
10+
return render(
11+
request,
12+
"flatpages/docs_publish.html",
13+
{},
14+
)

0 commit comments

Comments
 (0)