Skip to content

Commit

Permalink
Merge pull request #5 from Xpirix/frontend_update
Browse files Browse the repository at this point in the history
Frontend update
  • Loading branch information
Xpirix authored Nov 8, 2024
2 parents f0506f4 + e4e8739 commit a492015
Show file tree
Hide file tree
Showing 2,294 changed files with 51,703 additions and 21,540 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
run: cp .env.template .env


- name: Run docker-compose build
run: docker compose build

- name: Run the containers
run: docker compose up -d db devweb

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ qgis-app/api/tests/*/
qgis-app/whoosh_index/
docker-compose.override.yml
.env

# Webpack
node_modules
qgis-app/static/bundles
qgis-app/package-lock.json
qgis-app/webpack-stats.json

# Sustaining members template
qgis-app/templates/flatpages/sustaining_members.html
10 changes: 5 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Development Environment

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

- Build and spin container
```bash
Expand Down Expand Up @@ -65,7 +65,7 @@ pre-commit install --config .pre-commit-config.yaml

### Setting up a remote interpreter in PyCharm

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

Expand Down
11 changes: 9 additions & 2 deletions dockerize/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ exec:
@echo "------------------------------------------------------------------"
@docker compose -p $(PROJECT_ID) $(c)

loadmenu:
@echo
@echo "------------------------------------------------------------------"
@echo "Delete all simplemenu entries and load from fixtures/all_menu.json"
@echo "------------------------------------------------------------------"
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py clear_simplemenu
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py loaddata fixtures/all_menu.json
# ----------------------------------------------------------------------------
# D E V E L O P M E N T C O M M A N D S
# ----------------------------------------------------------------------------
Expand All @@ -222,7 +229,7 @@ devweb: db
@echo "------------------------------------------------------------------"
@echo "Running in DEVELOPMENT mode"
@echo "------------------------------------------------------------------"
@docker compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat
@docker compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat webpack

devweb-runserver: devweb
@echo
Expand All @@ -236,4 +243,4 @@ dbseed:
@echo "------------------------------------------------------------------"
@echo "Seed db with JSON data from /fixtures/*.json"
@echo "------------------------------------------------------------------"
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py loaddata fixtures/*.json'
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py loaddata fixtures/*.json'
4 changes: 4 additions & 0 deletions dockerize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ make devweb-runserver
make dbseed
```

- **loadmenu:** Clear all menu entries and load menu from JSON file at `fixtures/simplemenu.json`.
```sh
make loadmenu
```
15 changes: 14 additions & 1 deletion dockerize/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
- ${QGISPLUGINS_STATIC_VOLUME}:/home/web/static:rw
- ${QGISPLUGINS_MEDIA_VOLUME}:/home/web/media:rw
- celerybeat-schedule:/home/web/celerybeat-schedule:rw
command: uwsgi --ini /uwsgi.conf
command: bash -c "npm install && npm run build && uwsgi --ini /uwsgi.conf"
depends_on:
- db
- rabbitmq
Expand Down Expand Up @@ -90,6 +90,19 @@ services:
networks:
internal:

webpack:
container_name: qgis-plugins-webpack
build:
context: ${PWD}/../
dockerfile: dockerize/docker/Dockerfile
target: dev
working_dir: /home/web/django_project
command: npm start
volumes:
- ../qgis-app:/home/web/django_project
- ${QGISPLUGINS_STATIC_VOLUME}:/home/web/static:rw
- ${QGISPLUGINS_MEDIA_VOLUME}:/home/web/media:rw

rabbitmq:
image: rabbitmq:3.7-alpine
hostname: rabbitmq
Expand Down
9 changes: 9 additions & 0 deletions dockerize/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ ADD dockerize/docker/REQUIREMENTS.txt /REQUIREMENTS.txt

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

# Install NodeJS and bulma css webpack
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends wget && \
wget --no-check-certificate https://deb.nodesource.com/setup_20.x -O /tmp/node.sh && bash /tmp/node.sh && \
apt-get -qq update && apt-get -qq install -y nodejs build-essential

WORKDIR /home/web/django_project
COPY qgis-app/package.json /home/web/django_project/package.json
RUN npm install -g [email protected] && npm install -g [email protected] && npm install -g [email protected] && npm install

RUN mkdir -p /var/log/uwsgi

WORKDIR /home/web/django_project
Expand Down
4 changes: 4 additions & 0 deletions dockerize/docker/REQUIREMENTS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ uwsgi~=2.0
freezegun~=1.4

sentry-sdk~=2.2
django-webpack-loader~=3.1

beautifulsoup4~=4.12
setuptools~=75.1
2 changes: 1 addition & 1 deletion dockerize/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev li

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

Expand Down
4 changes: 2 additions & 2 deletions dockerize/scripts/renew-ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# 2021-11-12 11:10:00 UTC
# ...etc

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


docker compose -f /home/web/QGID-Plugins-Website/dockerize/docker-compose.yml -p qgis-plugins run certbot renew
docker compose -f /home/web/QGIS-Plugins-Website/dockerize/docker-compose.yml -p qgis-plugins run certbot renew
2 changes: 2 additions & 0 deletions dockerize/sites-enabled/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ if [ $# -eq 1 ]; then
echo "Run in prod mode"
CONF_FILE=prod.conf
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
exec nginx -g "daemon off;"
;;
# Production SSL mode, run using uwsgi
[Pp][Rr][Oo][Dd][-][Ss][Ss][Ll])
echo "Run in prod SSL mode"
CONF_FILE=prod-ssl.conf
ln -s /etc/nginx/sites-available/$CONF_FILE /etc/nginx/conf.d/$CONF_FILE
ln -s /etc/nginx/sites-available/redirections.conf /etc/nginx/redirections.conf
exec nginx -g "daemon off;"
;;
esac
Expand Down
6 changes: 6 additions & 0 deletions dockerize/sites-enabled/prod-ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ server {
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) ) {
return 403;
}

# Redirect planet and hub resources to the new location
include redirections.conf;
}

location /metabase/ {
Expand Down Expand Up @@ -220,6 +223,9 @@ server {
return 403;
}

# Redirect planet and hub resources to the new location
include redirections.conf;

}


Expand Down
3 changes: 3 additions & 0 deletions dockerize/sites-enabled/prod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ server {
return 403;
}

# Redirect planet and hub resources to the new location
include redirections.conf;

}


Expand Down
6 changes: 6 additions & 0 deletions dockerize/sites-enabled/redirections.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rewrite ^/planet$ https://planet.qgis.org permanent;
rewrite ^/styles(.*)$ https://hub.qgis.org/styles$1 permanent;
rewrite ^/geopackages(.*)$ https://hub.qgis.org/geopackages$1 permanent;
rewrite ^/models(.*)$ https://hub.qgis.org/models$1 permanent;
rewrite ^/wavefronts(.*)$ https://hub.qgis.org/wavefronts$1 permanent;
rewrite ^/layerdefinitions(.*)$ https://hub.qgis.org/layerdefinitions$1 permanent;
14 changes: 12 additions & 2 deletions qgis-app/custom_haystack_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ def build_form(self, form_kwargs=None):

def get_results(self):
"""
Fetches the results
Fetches the search results and sorts them in descending order based on the 'downloads' attribute.
If the 'downloads' attribute is not present or the object is None, it defaults to 0.
"""
return self.form.searchqueryset
results = self.form.searchqueryset
sort_by = 'downloads'
results = sorted(
results,
key=lambda x: int(
getattr(x.object, sort_by)
) if x.object is not None else 0,
reverse=True # Reverse the sort order
)
return results


urlpatterns = [
Expand Down
14 changes: 14 additions & 0 deletions qgis-app/docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.shortcuts import render
from django.utils.translation import gettext_lazy as _



def docs_publish(request):
"""
Renders the docs_publish page
"""
return render(
request,
"flatpages/docs_publish.html",
{},
)
Loading

0 comments on commit a492015

Please sign in to comment.