mirror of
https://github.com/Labelbase/Labelbase.git
synced 2026-08-13 12:33:23 +02:00
.
This commit is contained in:
parent
06bbbc5012
commit
2c7a4d0386
9 changed files with 72 additions and 20 deletions
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ from .views import (
|
|||
TreeMapsView,
|
||||
FixAndMergeLabelsView,
|
||||
LabelbaseDatatableView,
|
||||
LabelbasePortfolioView,
|
||||
#LabelbasePortfolioView,
|
||||
OutputStatUpdateRedirectView,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,21 @@
|
|||
|
||||
:)
|
||||
</pre>
|
||||
|
||||
{% comment %}
|
||||
|
||||
<h4>Responsible Disclosure</h4>
|
||||
|
||||
Send us an email to report any security related bugs or vulnerabilities at labelbase.space+security@proton.me.
|
||||
|
||||
<br>
|
||||
|
||||
You can encrypt your email message using our public PGP key.
|
||||
|
||||
<br>
|
||||
|
||||
Public key fingerprint: <tt>BC0A 05F7 6650 C669 99EE E203 ABAF FDA8 0EBE 8287</tt>.
|
||||
|
||||
{% endcomment %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ http {
|
|||
upstream labelbase_django {
|
||||
server labelbase_django:8000;
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
client_max_body_size 69M;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue