diff --git a/build-and-run-labelbase.sh b/build-and-run-labelbase.sh index 08c8051..bfa4ec3 100755 --- a/build-and-run-labelbase.sh +++ b/build-and-run-labelbase.sh @@ -1,6 +1,8 @@ -#!/bin/sh +#!/bin/bash -# git pull origin ... +docker-compose down # make sure Labelbase is terminated. + +# Check env vars first if [[ -z "${MYSQL_ROOT_PASSWORD}" ]]; then echo "Error: MYSQL_ROOT_PASSWORD environment variable is not set" @@ -16,4 +18,33 @@ else export $MYSQL_PASSWORD fi -docker-compose up --build +# Check git next + +LAST_GIT_COMMIT_FILE=".last_git_commit" + +if [ -f "$LAST_GIT_COMMIT_FILE" ]; then + LAST_COMMIT=$(cat "$LAST_GIT_COMMIT_FILE") +else + LAST_COMMIT="" +fi + +git fetch origin master + +LATEST_COMMIT=$(git rev-parse origin/master) + + + + + +if [ "$LATEST_COMMIT" != "$LAST_COMMIT" ]; then + echo "New Labelbase updates found. Pulling latest changes from $LAST_COMMIT, then build and run." + git pull origin master --no-rebase + echo $LATEST_COMMIT > "$LAST_GIT_COMMIT_FILE" + DOCKER_COMPOSE_COMMAND="up --build -d" +else + echo "Running Labelbase $LAST_COMMIT." + DOCKER_COMPOSE_COMMAND="up -d" +fi + +docker-compose $DOCKER_COMPOSE_COMMAND +echo "Excecute 'docker-compose down' to terminate Labelbase." diff --git a/django/knowledge_base/views.py b/django/knowledge_base/views.py index 7ce24a3..261a7d1 100644 --- a/django/knowledge_base/views.py +++ b/django/knowledge_base/views.py @@ -6,6 +6,7 @@ from .models import Category, Article, ExportSnapshot from .forms import JSONUploadForm from django.utils.text import slugify + class ExportJSONView(View): def get(self, request): categories = Category.objects.all().exclude(exclude_from_export=True) @@ -13,7 +14,7 @@ class ExportJSONView(View): for category in categories: articles = list(category.article_set.all().exclude(exclude_from_export=True).values()) data[category.name] = articles - export_snapshot = ExportSnapshot.objects.create( + ExportSnapshot.objects.create( exported_data=data ) return JsonResponse(data) @@ -37,8 +38,7 @@ class ImportJSONView(View): category = Category.objects.get(slug=slugify(category_name)) except Category.DoesNotExist: category = Category.objects.create(name=category_name, - slug=slugify(category_name)) - + slug=slugify(category_name)) for article_data in articles: try: article = Article.objects.get(slug=article_data['slug']) @@ -48,9 +48,9 @@ class ImportJSONView(View): article.save() except Article.DoesNotExist: Article.objects.create(title=article_data['title'], - content=article_data['content'], - category=category, - slug=article_data['slug']) + content=article_data['content'], + category=category, + slug=article_data['slug']) return JsonResponse({'message': 'Import successful'}) except json.JSONDecodeError: return JsonResponse({'error': 'Invalid JSON format'}, status=400) @@ -63,12 +63,14 @@ class IndexView(ListView): template_name = 'knowledge_base/index.html' context_object_name = 'categories' + class CategoryDetailView(DetailView): model = Category template_name = 'knowledge_base/category_detail.html' context_object_name = 'category' slug_url_kwarg = 'slug' + class ArticleDetailView(DetailView): model = Article template_name = 'knowledge_base/article_detail.html' diff --git a/django/labelbase/models.py b/django/labelbase/models.py index 667d68f..22433c1 100644 --- a/django/labelbase/models.py +++ b/django/labelbase/models.py @@ -71,7 +71,8 @@ class Labelbase(models.Model): max_length=10, choices=OPERATION_MODE_CHOICES, default='duplicate', - help_text="Choose the operation mode for handling entries with the same 'type' and 'ref'. The default mode is to create duplicate entries." + help_text=("Choose the operation mode for handling entries with the same" + "'type' and 'ref'. The default mode is to create duplicate entries.") ) MAINNET = 'mainnet' @@ -111,6 +112,7 @@ class Labelbase(models.Model): def get_hashtags_url(self): return reverse('labelbase_hashtags', kwargs={'labelbase_id': self.id}) + class Label(models.Model): """ Reference: diff --git a/django/labellabor/urls.py b/django/labellabor/urls.py index 7e409e5..04f8b05 100644 --- a/django/labellabor/urls.py +++ b/django/labellabor/urls.py @@ -38,7 +38,7 @@ from .views import ( TreeMapsView, FixAndMergeLabelsView, LabelbaseDatatableView, - LabelbasePortfolioView, + #LabelbasePortfolioView, OutputStatUpdateRedirectView, ) diff --git a/django/templates/about.html b/django/templates/about.html index 67e076f..274d9ff 100644 --- a/django/templates/about.html +++ b/django/templates/about.html @@ -10,4 +10,21 @@ :) + +{% comment %} + +

Responsible Disclosure

+ +Send us an email to report any security related bugs or vulnerabilities at labelbase.space+security@proton.me. + +
+ +You can encrypt your email message using our public PGP key. + +
+ +Public key fingerprint: BC0A 05F7 6650 C669 99EE  E203 ABAF FDA8 0EBE 8287. + +{% endcomment %} + {% endblock %} diff --git a/docker-compose.yml b/docker-compose.yml index 548dc3b..2f7c575 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,6 @@ services: volumes: - db_data:/var/lib/mysql - db_data:/run/mysqld - #- db_data:/run/secrets networks: - compose_network labelbase_django: @@ -30,14 +29,12 @@ services: - db_data:/var/lib/mysql - db_data:/run/mysqld - web_static:/app/static/ - #- db_data:/run/secrets depends_on: - labelbase_mysql restart: always networks: - compose_network environment: -# - DB_PASSWORD=${DB_PASSWORD} - MYSQL_USER=ulabelbase - MYSQL_DATABASE=labelbase - MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD @@ -48,7 +45,7 @@ services: context: ./nginx dockerfile: Dockerfile ports: - - "8080:8080" + - "127.0.0.1:8080:8080" volumes: - ./django:/app - web_static:/app/static/:ro diff --git a/make-exports.sh b/make-exports.sh index 7f68a17..736b498 100755 --- a/make-exports.sh +++ b/make-exports.sh @@ -20,8 +20,8 @@ MYSQL_ROOT_PASSWORD=$(generate_password 32) MYSQL_PASSWORD=$(generate_password 32) # Export the generated passwords as environment variables -echo "Exporting generated MySQL root password: $MYSQL_ROOT_PASSWORD" -echo "Exporting generated MySQL user password: $MYSQL_PASSWORD" +# echo "Exporting generated MySQL root password: $MYSQL_ROOT_PASSWORD" +# echo "Exporting generated MySQL user password: $MYSQL_PASSWORD" echo "" echo "Passwords stored in exports.sh for future usage. " #echo "Run 'source exports.sh' to use it." diff --git a/nginx/Dockerfile b/nginx/Dockerfile index c83fe96..6e8392e 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -3,5 +3,8 @@ FROM nginx:latest COPY nginx.conf /etc/nginx/ -#RUN rm /etc/nginx/conf.d/default.conf -#COPY default.conf /etc/nginx/conf.d/ +#RUN apt-get update && \ +# apt-get install -y gettext-base && \ +# rm -rf /var/lib/apt/lists/* + +#CMD /bin/bash -c "envsubst '$DOMAIN_NAME' < nginx.conf.template > /etc/nginx/nginx.conf" diff --git a/nginx/nginx.conf b/nginx/nginx.conf index eca8a7b..01a1f59 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -14,7 +14,7 @@ http { upstream labelbase_django { server labelbase_django:8000; } - + server { listen 8080; client_max_body_size 69M;