mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
refac: renamed 'post' -> 'article'
This commit is contained in:
+14
-14
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>GoCMS | Create post</title>
|
||||
<title>GoCMS | Create article</title>
|
||||
{{.Head}}
|
||||
<style>
|
||||
form {
|
||||
@@ -12,27 +12,27 @@
|
||||
<body class="text-dark">
|
||||
{{.Navbar}}
|
||||
<div class="container mt-3 text-black-50">
|
||||
<h1>Post - creation</h1>
|
||||
<p>Create a new post</p>
|
||||
<form action="create" method="post" class="d-flex align-items-center flex-column gap-3" id="createPostForm">
|
||||
<h1>Article - creation</h1>
|
||||
<p>Create a new article</p>
|
||||
<form action="create" method="post" class="d-flex align-items-center flex-column gap-3" id="createArticleForm">
|
||||
<div class="form-floating w-100">
|
||||
<input type="text" class="form-control {{ if .PageError.IsError }} is-invalid {{ end }}" id="name"
|
||||
name="name" placeholder="Chose the post name" value="{{ .Name }}">
|
||||
name="name" placeholder="Chose the article name" value="{{ .Name }}">
|
||||
<label for="name">Name</label>
|
||||
<div class="invalid-feedback">{{ .PageError.Message }}</div>
|
||||
</div>
|
||||
<button id="createPostButton" class="btn btn-primary w-100" disabled type="submit">
|
||||
<span class="createPostFormButtonLoading visually-hidden spinner-border spinner-border-sm"
|
||||
<button id="createArticleButton" class="btn btn-primary w-100" disabled type="submit">
|
||||
<span class="createArticleFormButtonLoading visually-hidden spinner-border spinner-border-sm"
|
||||
role="status"></span>
|
||||
<span class="createPostFormButtonDefault">Create</span>
|
||||
<span class="createArticleFormButtonDefault">Create</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const button = document.querySelector("#createPostButton")
|
||||
const button = document.querySelector("#createArticleButton")
|
||||
const inputs = document.querySelectorAll('input')
|
||||
const form = document.querySelector("#createPostForm")
|
||||
const form = document.querySelector("#createArticleForm")
|
||||
|
||||
function formFieldsEmpty() {
|
||||
return Array.from(inputs).some((input) => input.value === "")
|
||||
@@ -44,11 +44,11 @@
|
||||
|
||||
function setButtonLoading() {
|
||||
button.classList.add("disabled")
|
||||
button.querySelector(".createPostFormButtonDefault").classList.add("visually-hidden")
|
||||
button.querySelector(".createPostFormButtonLoading").classList.remove("visually-hidden")
|
||||
button.querySelector(".createArticleFormButtonDefault").classList.add("visually-hidden")
|
||||
button.querySelector(".createArticleFormButtonLoading").classList.remove("visually-hidden")
|
||||
}
|
||||
|
||||
function onCreatePostFormSubmit(event) {
|
||||
function onCreateArticleFormSubmit(event) {
|
||||
setButtonLoading()
|
||||
event.target.submit()
|
||||
}
|
||||
@@ -57,7 +57,7 @@
|
||||
if (event.target.tagName === "INPUT") setButtonDisabled()
|
||||
}
|
||||
|
||||
form.addEventListener('submit', onCreatePostFormSubmit)
|
||||
form.addEventListener('submit', onCreateArticleFormSubmit)
|
||||
window.addEventListener('input', onInput)
|
||||
setButtonDisabled()
|
||||
</script>
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>GoCMS | Post edition</title>
|
||||
<title>GoCMS | Article edition</title>
|
||||
{{.Head}}
|
||||
</head>
|
||||
<body class="text-dark vh-100 d-flex flex-column">
|
||||
@@ -9,8 +9,8 @@
|
||||
<form class="container mt-3 text-black-50 d-flex flex-column h-100" action="edit" method="post">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<h1>Post - edition</h1>
|
||||
<label for="postBody">Edition</label>
|
||||
<h1>Article - edition</h1>
|
||||
<label for="articleBody">Edition</label>
|
||||
</div>
|
||||
{{ if .Alert.Message }}
|
||||
<div class="alert {{ if .Alert.IsError }} alert-danger {{ else }} alert-success {{ end }} alert-dismissible"
|
||||
@@ -30,14 +30,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-black-50 d-flex align-items-center justify-content-center h-100 py-3">
|
||||
<textarea id="postBody" name="postBody">{{.Post.Body}}</textarea>
|
||||
<textarea id="articleBody" name="articleBody">{{.Article.Body}}</textarea>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="/static/tinymce/js/tinymce/tinymce.min.js"></script>
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: '#postBody',
|
||||
selector: '#articleBody',
|
||||
promotion: false,
|
||||
plugins: 'image lists visualblocks',
|
||||
toolbar: 'undo redo | formatselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | removeformat | image',
|
||||
@@ -52,7 +52,7 @@
|
||||
images_upload_handler: (blobInfo, progress) => new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.withCredentials = false;
|
||||
xhr.open('POST', "/post/{{.Post.ID}}/image/create");
|
||||
xhr.open('POST', "/article/{{.Article.ID}}/image/create");
|
||||
|
||||
xhr.upload.onprogress = (e) => {
|
||||
progress(e.loaded / e.total * 100);
|
||||
+20
-20
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>GoCMS | Posts</title>
|
||||
<title>GoCMS | Articles</title>
|
||||
{{.Head}}
|
||||
|
||||
<style>
|
||||
@@ -15,8 +15,8 @@
|
||||
<body class="text-dark">
|
||||
{{.Navbar}}
|
||||
<div class="container mt-3 text-black-50">
|
||||
<h1>Posts</h1>
|
||||
<p>List of your posts</p>
|
||||
<h1>Articles</h1>
|
||||
<p>List of your articles</p>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -30,59 +30,59 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
<form action="post/create" method="get">
|
||||
<button class="btn btn-sm btn-link w-100 h-100" type="submit">Create a new post...</button>
|
||||
<form action="article/create" method="get">
|
||||
<button class="btn btn-sm btn-link w-100 h-100" type="submit">Create a new article...</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{ range $post := .Posts }}
|
||||
{{ range $article := .Articles }}
|
||||
<tr>
|
||||
<td>{{ $post.Title }}</td>
|
||||
<td class="date">{{ $post.CreatedAt }}</td>
|
||||
<td class="date">{{ $post.UpdatedAt }}</td>
|
||||
<td>{{ if $post.IsOnline }}🟢 Online{{ else }}🟠 Offline{{ end }}</td>
|
||||
<td>{{ $article.Title }}</td>
|
||||
<td class="date">{{ $article.CreatedAt }}</td>
|
||||
<td class="date">{{ $article.UpdatedAt }}</td>
|
||||
<td>{{ if $article.IsOnline }}🟢 Online{{ else }}🟠 Offline{{ end }}</td>
|
||||
<td>
|
||||
<a href="/post/{{ $post.ID }}/edit" class="btn btn-outline-primary btn-sm">
|
||||
<a href="/article/{{ $article.ID }}/edit" class="btn btn-outline-primary btn-sm">
|
||||
<svg width="12px" height="12px" fill="currentColor">
|
||||
<use xlink:href="/static/bootstrap-icons.svg#pen"/>
|
||||
</svg>
|
||||
</a>
|
||||
{{ if $post.IsOnline }}
|
||||
<a href="/post/{{ $post.ID }}/unpublish" class="btn btn-outline-info btn-sm">
|
||||
{{ if $article.IsOnline }}
|
||||
<a href="/article/{{ $article.ID }}/unpublish" class="btn btn-outline-info btn-sm">
|
||||
<svg width="12px" height="12px" fill="currentColor">
|
||||
<use xlink:href="/static/bootstrap-icons.svg#eye-slash"/>
|
||||
</svg>
|
||||
</a>
|
||||
{{ else }}
|
||||
<a href="/post/{{ $post.ID }}/publish" class="btn btn-outline-info btn-sm">
|
||||
<a href="/article/{{ $article.ID }}/publish" class="btn btn-outline-info btn-sm">
|
||||
<svg width="12px" height="12px" fill="currentColor">
|
||||
<use xlink:href="/static/bootstrap-icons.svg#eye"/>
|
||||
</svg>
|
||||
</a>
|
||||
{{ end }}
|
||||
<a href="/post/{{ $post.Title }}/delete" class="btn btn-outline-danger btn-sm" data-bs-toggle="modal"
|
||||
data-bs-target="#{{ $post.ID }}">
|
||||
<a href="/article/{{ $article.Title }}/delete" class="btn btn-outline-danger btn-sm" data-bs-toggle="modal"
|
||||
data-bs-target="#{{ $article.ID }}">
|
||||
<svg width=" 12px" height="12px" fill="currentColor">
|
||||
<use xlink:href="/static/bootstrap-icons.svg#trash"/>
|
||||
</svg>
|
||||
</a>
|
||||
<div class="modal fade" id="{{ $post.ID }}" tabindex="-1" aria-labelledby="{{ $post.ID }}Label"
|
||||
<div class="modal fade" id="{{ $article.ID }}" tabindex="-1" aria-labelledby="{{ $article.ID }}Label"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="{{ $post.ID }}Label">Delete post</h1>
|
||||
<h1 class="modal-title fs-5" id="{{ $article.ID }}Label">Delete post</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>You are about to delete the post <b>« {{ $post.Title }} »</b>, this is definitive,
|
||||
<p>You are about to delete the post <b>« {{ $article.Title }} »</b>, this is definitive,
|
||||
are you sure?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel
|
||||
</button>
|
||||
<a href="/post/{{$post.ID}}/delete" class="btn btn-danger">Delete</a>
|
||||
<a href="/article/{{$article.ID}}/delete" class="btn btn-danger">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,7 +16,7 @@
|
||||
<a class="nav-link" href="/home">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/post">Posts</a>
|
||||
<a class="nav-link" href="/article">Articles</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/integration">Integration</a>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<div class="container mt-3 text-black-50">
|
||||
<h1>Home</h1>
|
||||
<p>Welcome on GoCMS !</p>
|
||||
<a href="/post">
|
||||
<button class="btn btn-outline-primary">Posts »</button>
|
||||
<a href="/article">
|
||||
<button class="btn btn-outline-primary">Articles »</button>
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
<div class="mt-5">
|
||||
<section>
|
||||
<h2>Introduction</h2>
|
||||
<p>This documentation explains how to integrate our headless CMS API to retrieve post data via the <code>/post</code>
|
||||
<p>This documentation explains how to integrate our headless CMS API to retrieve article data via the <code>/article</code>
|
||||
route.</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>/v1/post</h2>
|
||||
<p>The <code>{{ .Host }}/v1/post</code> route returns a list of posts in JSON format. Each post has the
|
||||
<h2>/v1/article</h2>
|
||||
<p>The <code>{{ .Host }}/v1/article</code> route returns a list of articles in JSON format. Each article has the
|
||||
following
|
||||
structure:</p>
|
||||
<pre>
|
||||
<code>[
|
||||
{
|
||||
"id": 12,
|
||||
"title": "This is a post!",
|
||||
"title": "This is a article!",
|
||||
"body": "<p>?</p>\r\n<p><img src=\"../../static/uploadedImages/649691a8-4f2e-48ca-9abe-27a60621d2e4.png\"
|
||||
alt=\"\" width=\"391\" height=\"465\"></p>",
|
||||
"created_at": "2024-06-13T15:30:55.3563238+02:00",
|
||||
@@ -34,21 +34,21 @@
|
||||
</pre>
|
||||
</section>
|
||||
<section>
|
||||
<h2>/v1/post/{id}</h2>
|
||||
<p>The <code>{{ .Host }}/v1/post/{id}</code> route returns a single post in JSON format. The post has the
|
||||
<h2>/v1/article/{id}</h2>
|
||||
<p>The <code>{{ .Host }}/v1/article/{id}</code> route returns a single article in JSON format. The article has the
|
||||
following
|
||||
structure:</p>
|
||||
<pre>
|
||||
<code>{
|
||||
"id": 12,
|
||||
"title": "ravioli sans le ra et le i",
|
||||
"title": "ravioli",
|
||||
"body": "<\p>?<\/p>\r\n<\p><\img src=\"../../static/uploadedImages/649691a8-4f2e-48ca-9abe-27a60621d2e4.png\" alt=\"\"
|
||||
width=\"391\" height=\"465\"><\/p>",
|
||||
"images": [
|
||||
{
|
||||
"id": 17,
|
||||
"path": "/static/uploadedImages/649691a8-4f2e-48ca-9abe-27a60621d2e4.png",
|
||||
"post_id": 0,
|
||||
"article_id": 0,
|
||||
"created_at": "2024-06-13T15:31:09.728359+02:00",
|
||||
"updated_at": "2024-06-13T15:31:09.728359+02:00"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user