From 6fa7cade9da70df4e84f646a51d006e1f72b64c3 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 31 Jan 2023 18:39:59 +0100 Subject: [PATCH] first spec --- .gitignore | 1 - Makefile | 48 ++++++++++++++ netoik-home.spec | 62 ++++++++++++++++++ nginx/netoik.io.conf | 29 ++++++++ nginx/samuel-campos.fr.conf | 29 ++++++++ nginx/www.netoik.io.conf | 32 +++++++++ nginx/www.samuel-campos.fr.conf | 24 +++++++ .../loading.png => captcha-loading.png} | Bin ...navailable.png => captcha-unavailable.png} | Bin src/assets/js/scripts.js | 2 +- src/index.html | 2 +- 11 files changed, 226 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100644 netoik-home.spec create mode 100644 nginx/netoik.io.conf create mode 100644 nginx/samuel-campos.fr.conf create mode 100644 nginx/www.netoik.io.conf create mode 100644 nginx/www.samuel-campos.fr.conf rename src/assets/img/{captcha/loading.png => captcha-loading.png} (100%) rename src/assets/img/{captcha/unavailable.png => captcha-unavailable.png} (100%) diff --git a/.gitignore b/.gitignore index 0558337..485dee6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .idea -*.conf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..349090e --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +NAME = netoik-home +VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g") +BRANCH = $(shell [ -d ".git" ] && git branch --show-current) + +SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}") +VARDIR = $(shell rpm --eval "%{_var}") + +BOOTSTRAP_VERSION = 5.1.3 +FONTAWESOME_VERSION = 6.1.1 +JQUERY_VERSION = 3.6.0 + +.PHONY: version +version: + @echo $(VERSION) + +.PHONY: tarball +tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz + +$(HOME)/rpmbuild/SOURCES/$(NAME)-%.tar.gz: . + git archive --format=tar.gz --output=$@ --prefix=$(NAME)-$(VERSION)/ --worktree-attributes --verbose $(BRANCH) + +.PHONY: install +install: + install -D --target-directory $(DESTDIR)$(SYSCONFDIR)/nginx/conf.d nginx/*.conf + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME) src/*.{html,ico} + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/bootstrap-$(BOOTSTRAP_VERSION) src/assets/bootstrap-$(BOOTSTRAP_VERSION)/*.js + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/css src/assets/css/*.css + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/docs src/assets/docs/*.pdf + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/fontawesome-$(FONTAWESOME_VERSION) src/assets/fontawesome-$(FONTAWESOME_VERSION)/*.{js,css} + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/googleapis src/assets/googleapis/roboto + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/img src/assets/img/*.{png,svg} + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/img/services src/assets/img/services/*.svg + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/jquery-$(JQUERY_VERSION) src/assets/jquery-$(JQUERY_VERSION)/*.js + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/js src/assets/js/*.js + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/share/cg src/share/cg/index.html + install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/share/in src/share/in/index.html + +.PHONY: bootstrap_version +bootstrap_version: + @echo $(BOOTSTRAP_VERSION) + +.PHONY: fontawesome_version +fontawesome_version: + @echo $(FONTAWESOME_VERSION) + +.PHONY: jquery_version +jquery_version: + @echo $(JQUERY_VERSION) diff --git a/netoik-home.spec b/netoik-home.spec new file mode 100644 index 0000000..f3f7667 --- /dev/null +++ b/netoik-home.spec @@ -0,0 +1,62 @@ +Name: netoik-home +Version: %(make version) +Release: 1%{?dist} +Summary: Netoik home page + +License: GPLv3 +URL: https://www.netoik.io +Source0: %{name}-%{version}.tar.gz + +BuildArch: x86_64 +BuildRequires: make +Requires: netoik-api + +%description +Netoik home page + +%prep +%autosetup -v + +%install +%make_install + +%post +ln --symbolic %{_var}/netoik-api/captcha %{_var}/www/%{name}/assets/img/captcha + +%preun +rm %{_var}/www/%{name}/assets/img/captcha + +%files +%define bootstrap_version %(make bootstrap_version) +%define fontawesome_version %(make fontawesome_version) +%define jquery_version %(make jquery_version) +%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/netoik.io.conf +%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/samuel-campos.fr.conf +%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/www.netoik.io.conf +%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/www.samuel-campos.fr.conf +%attr(755, root, root) %dir %{_var}/www/%{name} +%attr(644, root, root) %{_var}/www/%{name}/*.{html,ico} +%attr(755, root, root) %dir %{_var}/www/%{name}/assets +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/bootstrap-%{bootstrap_version} +%attr(644, root, root) %{_var}/www/%{name}/assets/bootstrap-%{bootstrap_version}/*.js +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/css +%attr(644, root, root) %{_var}/www/%{name}/assets/css/*.css +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/docs +%attr(644, root, root) %{_var}/www/%{name}/assets/docs/*.pdf +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/fontawesome-%{fontawesome_version} +%attr(644, root, root) %{_var}/www/%{name}/assets/fontawesome-%{fontawesome_version}/*.{js,css} +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/googleapis +%attr(644, root, root) %{_var}/www/%{name}/assets/googleapis/roboto +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/img +%attr(644, root, root) %{_var}/www/%{name}/assets/img/*.{png,svg} +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/img/services +%attr(644, root, root) %{_var}/www/%{name}/assets/img/services/*.svg +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/jquery-%(make jquery_version) +%attr(644, root, root) %{_var}/www/%{name}/assets/jquery-%{jquery_version}/*.js +%attr(755, root, root) %dir %{_var}/www/%{name}/assets/js +%attr(644, root, root) %{_var}/www/%{name}/assets/js/*.js +%attr(755, root, root) %dir %{_var}/www/%{name}/share +%attr(755, root, root) %dir %{_var}/www/%{name}/share/cg +%attr(644, root, root) %{_var}/www/%{name}/share/cg/index.html +%attr(755, root, root) %dir %{_var}/www/%{name}/share/in +%attr(644, root, root) %{_var}/www/%{name}/share/in/index.html diff --git a/nginx/netoik.io.conf b/nginx/netoik.io.conf new file mode 100644 index 0000000..c9b0c7c --- /dev/null +++ b/nginx/netoik.io.conf @@ -0,0 +1,29 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name netoik.io; + + # Configure secure access. + ssl_certificate /etc/letsencrypt/live/netoik.io/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/netoik.io/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} + +server { + listen 80; + listen [::]:80; + server_name netoik.io; + + # Let access to certbot challenge files. + location /.well-known/acme-challenge/ { + root /var/www/; + } + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} diff --git a/nginx/samuel-campos.fr.conf b/nginx/samuel-campos.fr.conf new file mode 100644 index 0000000..7b573e5 --- /dev/null +++ b/nginx/samuel-campos.fr.conf @@ -0,0 +1,29 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name samuel-campos.fr; + + # Configure secure access. + ssl_certificate /etc/letsencrypt/live/samuel-campos.fr/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/samuel-campos.fr/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} + +server { + listen 80; + listen [::]:80; + server_name samuel-campos.fr; + + # Let access to certbot challenge files. + location /.well-known/acme-challenge/ { + root /var/www/; + } + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} diff --git a/nginx/www.netoik.io.conf b/nginx/www.netoik.io.conf new file mode 100644 index 0000000..7852896 --- /dev/null +++ b/nginx/www.netoik.io.conf @@ -0,0 +1,32 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name www.netoik.io; + root /var/www/netoik-home/; + + # Configure secure access. + ssl_certificate /etc/letsencrypt/live/netoik.io/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/netoik.io/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # Forbide access to hidden files. + location ~ /\. { + return 404; + } + + # Forward api requests to back service. + location /api/ { + proxy_pass http://127.0.0.1:8080; + } +} + +server { + listen 80; + listen [::]:80; + server_name www.netoik.io; + + # Redirect to https. + return 301 https://$host$request_uri; +} diff --git a/nginx/www.samuel-campos.fr.conf b/nginx/www.samuel-campos.fr.conf new file mode 100644 index 0000000..cda8c6c --- /dev/null +++ b/nginx/www.samuel-campos.fr.conf @@ -0,0 +1,24 @@ +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name www.samuel-campos.fr; + + # Configure secure access. + ssl_certificate /etc/letsencrypt/live/samuel-campos.fr/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/samuel-campos.fr/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} + +server { + listen 80; + listen [::]:80; + server_name www.samuel-campos.fr; + + # Redirect to homepage. + return 301 https://www.netoik.io$request_uri; +} diff --git a/src/assets/img/captcha/loading.png b/src/assets/img/captcha-loading.png similarity index 100% rename from src/assets/img/captcha/loading.png rename to src/assets/img/captcha-loading.png diff --git a/src/assets/img/captcha/unavailable.png b/src/assets/img/captcha-unavailable.png similarity index 100% rename from src/assets/img/captcha/unavailable.png rename to src/assets/img/captcha-unavailable.png diff --git a/src/assets/js/scripts.js b/src/assets/js/scripts.js index 2153365..3b18372 100644 --- a/src/assets/js/scripts.js +++ b/src/assets/js/scripts.js @@ -151,7 +151,7 @@ window.addEventListener('load', _ => { $("#captchaImage").attr("src", "/assets/img/captcha/"+data.id+".png"); $("#captchaId").val(data.id); }).fail(_ => { - $("#captchaImage").attr("src", "/assets/img/captcha/unavailable.png"); + $("#captchaImage").attr("src", "/assets/img/captcha-unavailable.png"); $("#captchaId").val(); }); } diff --git a/src/index.html b/src/index.html index 5d42e12..d053065 100644 --- a/src/index.html +++ b/src/index.html @@ -313,7 +313,7 @@
- captcha error + captcha error