From 904aa85b199255ca61c57e979f8714bd36018ecd Mon Sep 17 00:00:00 2001 From: JotaChina Date: Wed, 10 Dec 2025 14:39:51 -0300 Subject: [PATCH] upload samples com login --- _data/samples-manifest.json | 18 ++++++++++++++++++ _layouts/projetos.html | 1 - pages/automacao.md | 1 - pages/bassline.md | 1 - pages/beats.md | 1 - pages/bpm.md | 1 - pages/buscas.md | 1 - pages/enviaProjeto.md | 1 - pages/instruments.md | 1 - pages/pattern.md | 1 - pages/plugin.md | 1 - pages/projetos.md | 1 - pages/sample.md | 1 - scripts/handler/upload_server.py | 23 ++++++++++++++--------- 14 files changed, 32 insertions(+), 21 deletions(-) diff --git a/_data/samples-manifest.json b/_data/samples-manifest.json index d23e1468..7396eca8 100644 --- a/_data/samples-manifest.json +++ b/_data/samples-manifest.json @@ -2395,11 +2395,26 @@ }, "Teste": { "Testes": { + "gravacao_14-13-31.ogg": { + "_isFile": true + }, + "gravacao_14-27-58.ogg": { + "_isFile": true + }, + "gravacao_14-29-41.ogg": { + "_isFile": true + }, "bassdrum_acoustic01_-_Copia.ogg": { "_isFile": true }, "gravacao_14-34-59.ogg": { "_isFile": true + }, + "gravacao_14-18-59.ogg": { + "_isFile": true + }, + "gravacao_22-34-01.ogg": { + "_isFile": true } } }, @@ -2824,6 +2839,9 @@ "_isFile": true } }, + "gravacao_22-42-08.ogg": { + "_isFile": true + }, "drums": { "hihat_opened03.ogg": { "_isFile": true diff --git a/_layouts/projetos.html b/_layouts/projetos.html index 045f25cf..8adf289b 100755 --- a/_layouts/projetos.html +++ b/_layouts/projetos.html @@ -6,7 +6,6 @@ title: "{{ page.file }}"

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/automacao.md b/pages/automacao.md index 92b0cfa3..dad2d6ea 100755 --- a/pages/automacao.md +++ b/pages/automacao.md @@ -10,7 +10,6 @@ permalink: /automation/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/bassline.md b/pages/bassline.md index 8bfab24d..4919ca84 100755 --- a/pages/bassline.md +++ b/pages/bassline.md @@ -10,7 +10,6 @@ permalink: /bassline/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/beats.md b/pages/beats.md index f508d271..2b9636ed 100755 --- a/pages/beats.md +++ b/pages/beats.md @@ -6,7 +6,6 @@ permalink: /beats/
- {% include modal_login.html %}

diff --git a/pages/bpm.md b/pages/bpm.md index ca0e754c..e327334d 100755 --- a/pages/bpm.md +++ b/pages/bpm.md @@ -10,7 +10,6 @@ permalink: /bpm/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/buscas.md b/pages/buscas.md index d0e9de7e..37058a53 100755 --- a/pages/buscas.md +++ b/pages/buscas.md @@ -9,7 +9,6 @@ permalink: /buscas/
- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/enviaProjeto.md b/pages/enviaProjeto.md index 5d7d5e28..2c2eaf3b 100755 --- a/pages/enviaProjeto.md +++ b/pages/enviaProjeto.md @@ -9,7 +9,6 @@ permalink: /envie_seu_projeto/
- {% include modal_login.html %}
diff --git a/pages/instruments.md b/pages/instruments.md index 99b38638..06fe7306 100755 --- a/pages/instruments.md +++ b/pages/instruments.md @@ -10,7 +10,6 @@ permalink: /instruments/
- {% include modal_login.html %}
diff --git a/pages/pattern.md b/pages/pattern.md index 577644c0..e59c6575 100755 --- a/pages/pattern.md +++ b/pages/pattern.md @@ -10,7 +10,6 @@ permalink: /pattern/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/plugin.md b/pages/plugin.md index a3d51af5..fda88887 100755 --- a/pages/plugin.md +++ b/pages/plugin.md @@ -10,7 +10,6 @@ permalink: /plugin/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/projetos.md b/pages/projetos.md index 8dcee14f..8558b03d 100755 --- a/pages/projetos.md +++ b/pages/projetos.md @@ -7,7 +7,6 @@ permalink: /projetos/

- {% include modal_login.html %}
{% include sidebar.html %} diff --git a/pages/sample.md b/pages/sample.md index 988bd3c6..a2e1d701 100755 --- a/pages/sample.md +++ b/pages/sample.md @@ -10,7 +10,6 @@ permalink: /sample/
- {% include modal_login.html %}
diff --git a/scripts/handler/upload_server.py b/scripts/handler/upload_server.py index 09f33737..f923a6d5 100755 --- a/scripts/handler/upload_server.py +++ b/scripts/handler/upload_server.py @@ -9,7 +9,7 @@ import shutil import time import io -from flask import Flask, request, jsonify, send_file +from flask import Flask, request, jsonify, send_file, redirect from flask_cors import CORS from werkzeug.utils import secure_filename @@ -21,14 +21,12 @@ from flask_admin import Admin, AdminIndexView, expose from flask_admin.contrib.sqla import ModelView from main import process_single_file, rebuild_indexes, generate_manifests, slugify -from utils import ALLOWED_EXTENSIONS, ALLOWED_SAMPLE_EXTENSIONS, MMP_FOLDER, MMPZ_FOLDER, DATA_FOLDER, CERT_PATH, KEY_PATH, BASE_DATA, SRC_MMPSEARCH, SAMPLE_SRC, METADATA_FOLDER, XML_IMPORTED_PATH_PREFIX, SAMPLE_MANIFEST +from utils import ALLOWED_EXTENSIONS, ALLOWED_SAMPLE_EXTENSIONS, MMP_FOLDER, MMPZ_FOLDER, DATA_FOLDER, BASE_DATA, SRC_MMPSEARCH, SAMPLE_SRC, METADATA_FOLDER, XML_IMPORTED_PATH_PREFIX, SAMPLE_MANIFEST app = Flask(__name__) # --- CONFIGURAÇÃO DE SEGURANÇA E BANCO --- -# IMPORTANTE: Troque esta chave em produção! app.config['SECRET_KEY'] = '25de5592bf94c2ca18e27baa0ae2d4ee22a63012f32e1be719d31f530c215a387b9ec0c9d96be38e80a7ccdd859e04408facefff8fd9119e7f5a2d987d85abb7' -# O banco ficará salvo em /nethome/jotachina/projetos/mmpSearch/users.db (BASE_DATA) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(DATA_FOLDER, 'users.db') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -56,12 +54,17 @@ class SecureModelView(ModelView): # Retorna erro JSON ou redireciona (como é painel, melhor redirecionar ou negar) return jsonify({"error": "Acesso restrito a administradores."}), 403 -# Classe para proteger a Home do Admin (Dashboard) class SecureIndexView(AdminIndexView): @expose('/') def index(self): if not current_user.is_authenticated or not current_user.is_admin: - return jsonify({"error": "Acesso restrito."}), 403 + # Em vez de retornar JSON, redireciona para a home + # O usuário verá o botão de login lá. + return redirect('/') + + # OU, se quiser ser mais explícito, retorna 403 mas em HTML (opcional) + # return "

Acesso Negado

Você precisa ser admin.

", 403 + return super(SecureIndexView, self).index() # Cria o banco na inicialização se não existir @@ -72,7 +75,7 @@ with app.app_context(): def load_user(user_id): return User.query.get(int(user_id)) -# --- SUAS FUNÇÕES UTILITÁRIAS MANTIDAS --- +# --- FUNÇÕES UTILITÁRIAS --- def allowed_file(filename): return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS @@ -81,8 +84,9 @@ def allowed_sample(filename): return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_SAMPLE_EXTENSIONS def run_jekyll_build(): + BUNDLE_PATH = "/nethome/jotachina/projetos/mmpSearch/vendor/bundle/ruby/3.2.0/bin/bundle" print("Iniciando build do Jekyll...") - command = ["bundle", "exec", "jekyll", "build", "--destination", "/var/www/html/trens/mmpSearch/"] + command = [BUNDLE_PATH, "exec", "jekyll", "build", "--destination", "/var/www/html/trens/mmpSearch/"] try: subprocess.run(command, check=True, cwd=BASE_DATA, capture_output=True, text=True) print("Jekyll Build Sucesso!") @@ -436,7 +440,8 @@ def upload_sample_standalone(): admin = Admin( app, name='MMP Admin', - index_view=SecureIndexView(url='/api/admin') + url='/api/admin', + index_view=SecureIndexView() ) # Adiciona a visualização da tabela de Usuários