Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Parser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CMS
Parser
Commits
0828bf6f
Commit
0828bf6f
authored
9 months ago
by
Richard Fernando Heise Ferreira
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue-3/Update-script-for-projects' into 'main'
issue
#3
: UPDATE including rotes for Projects collection type in the script See merge request
!3
parents
b74c9339
cae08459
Branches
Branches containing commit
No related tags found
1 merge request
!3
issue #3: UPDATE including rotes for Projects collection type in the script
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.py
+35
-1
35 additions, 1 deletion
app.py
with
35 additions
and
1 deletion
app.py
+
35
−
1
View file @
0828bf6f
...
@@ -6,6 +6,7 @@ app = Flask(__name__)
...
@@ -6,6 +6,7 @@ app = Flask(__name__)
# Diretórios onde os arquivos Markdown serão salvos
# Diretórios onde os arquivos Markdown serão salvos
DIR_O_C3SL
=
os
.
path
.
join
(
os
.
getcwd
(),
'
../cms-c3sl/themes/c3sl/exampleSite/content
'
)
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_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
):
def
create_or_update_post
(
post_id
,
data
,
event
,
content_type
):
if
not
data
:
if
not
data
:
...
@@ -26,6 +27,29 @@ layout: 'legal'
...
@@ -26,6 +27,29 @@ layout: 'legal'
---
---
{
content
}
{
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
:
else
:
attributes
=
data
.
get
(
'
entry
'
,
{})
attributes
=
data
.
get
(
'
entry
'
,
{})
content
=
attributes
.
get
(
'
Descricao
'
,
''
)
content
=
attributes
.
get
(
'
Descricao
'
,
''
)
...
@@ -75,6 +99,16 @@ def delete_post(post_id, content_type):
...
@@ -75,6 +99,16 @@ def delete_post(post_id, content_type):
#print(f"Post com ID {post_id} deletado")
#print(f"Post com ID {post_id} deletado")
else
:
else
:
print
(
f
"
Arquivo com ID
{
post_id
}
não encontrado para exclusão
"
)
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
'
])
@app.route
(
'
/run-script
'
,
methods
=
[
'
POST
'
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment