diff --git a/app.py b/app.py index 01507a87320701f727ac9c3b79f612b0e2558330..5f769c060e40d924ceb553f1181eadafe13c0372 100644 --- a/app.py +++ b/app.py @@ -6,6 +6,7 @@ app = Flask(__name__) # Diretórios onde os arquivos Markdown serão salvos DIR_O_C3SL = os.path.join(os.getcwd(), '../cms-c3sl/themes/c3sl/exampleSite/content') DIR_POSTS = os.path.join(os.getcwd(), '../cms-c3sl/themes/c3sl/exampleSite/content/noticia') +DIR_PROJECTS = os.path.join(os.getcwd(), '../cms-c3sl/themes/c3sl/exampleSite/content/projetos') def create_or_update_post(post_id, data, event, content_type): if not data: @@ -26,6 +27,29 @@ layout: 'legal' --- {content} """ + elif content_type == 'projeto': + attributes = data.get('entry', {}) + title = attributes.get('Titulo', '') + status = attributes.get('Status', '') + partner = attributes.get('Parceiro', '') + content = attributes.get('Descricao', '') + + file_name = f"{post_id}.md" + file_path = os.path.join(DIR_PROJECTS, file_name) + + edited_line = 'Edited: true\n' if event == 'entry.update' else '' + + content_markdown = f"""--- +title: "{title}" +author: " Parceiro: {partner}" +status: "{status}" +{edited_line}ShowReadingTime: true +--- +--- + +{content} +""" + else: attributes = data.get('entry', {}) content = attributes.get('Descricao', '') @@ -67,7 +91,7 @@ summary: "{summary}" def delete_post(post_id, content_type): if content_type == 'post': - file_name = f"{post_id}.md" + file_name = f"{post_id}.md" file_path = os.path.join(DIR_POSTS, file_name) if os.path.exists(file_path): @@ -75,6 +99,16 @@ def delete_post(post_id, content_type): #print(f"Post com ID {post_id} deletado") else: print(f"Arquivo com ID {post_id} não encontrado para exclusão") + elif content_type == 'projeto': + file_name = f"{post_id}.md" + file_path = os.path.join(DIR_PROJECTS, file_name) + + if os.path.exists(file_path): + os.remove(file_path) + #print(f"Post com ID {post_id} deletado") + else: + print(f"Arquivo com ID {post_id} não encontrado para exclusão") + @app.route('/run-script', methods=['POST'])