-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditBlog.html
197 lines (186 loc) · 9.38 KB
/
editBlog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create New Blog</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="/file.css">
<link rel="stylesheet" href="/richtexteditor/rte_theme_default.css" />
<script type="text/javascript" src="/richtexteditor/rte.js"></script>
<script type="text/javascript" src='/richtexteditor/plugins/all_plugins.js'></script>
</head>
<body style="background-color: #F1F1F1;">
<div class="container p-2">
<h1 class="my-3 fs-4 roboto-medium">
<svg class="me-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path
d="M10.78 19.03a.75.75 0 0 1-1.06 0l-6.25-6.25a.75.75 0 0 1 0-1.06l6.25-6.25a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L5.81 11.5h14.44a.75.75 0 0 1 0 1.5H5.81l4.97 4.97a.75.75 0 0 1 0 1.06Z">
</path>
</svg>
Edit Blog Post
</h1>
<div class="row">
<div class="col-8">
<div class="card roboto-regular">
<div class="card-body">
<div class="form-group">
<label for="blogTitle" class="form-label">Title</label>
<input type="text" class="form-control" id="blogTitle" />
</div>
<div class="form-group">
<label for="tiny" class="form-label">Content</label>
<textarea style="width: 100% important;resize: none !important;" id="tiny"></textarea>
</div>
</div>
</div>
<div class="card my-3">
<div class="card-body">
<h6 class="card-title d-block mb-3 roboto-bold">Expert</h6>
<div class="form-group roboto-regular">
<label for="summary" class="form-label">Add a summary of the post to appear on your home
page
or blog.</label>
<textarea class="form-control resize-none" style="height: 200px;" id="summary"></textarea>
</div>
</div>
</div>
<div class="card my-3">
<div class="card-header bg-white">
<h6 class="card-title d-block my-1 mb-3 roboto-bold">Search engine listing preview</h6>
<p class="subtitle roboto-regular">Add a description to see how this Blog post might appear
in a search
engine
listing</p>
</div>
<div class="card-body roboto-regular">
<div class="form-group">
<label for="meta-title" class="form-label">Meta Page Title</label>
<input class="form-control" id="meta-title"></input>
</div>
<div class="form-group">
<label for="meta-summary" class="form-label">Meta Page Description</label>
<textarea class="form-control" id="meta-summary"></textarea>
</div>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-body">
<h6 class="card-title roboto-bold mb-3">
Featured Image
</h6>
<form method="post" action="#" id="#">
<div class="form-group files">
<input type="file" id="file" accept="image/*" class="form-control"
style="opacity:0;height:100%">
</div>
<div class="d-flex w-100 border-2 rounded-1 align-items-center justify-content-center">
<div id="preview"></div>
</div>
</form>
</div>
</div>
<div class="card my-3" style="background-color: #F7F7F7;">
<div class="card-body">
<h6 class="card-title roboto-bold mb-3">
Organization
</h6>
<div class="form-group roboto-regular">
<label for="auther" class="form-label">Author</label>
<input type="text" class="form-control" id="author" />
</div>
<div class="form-group">
<label for="categories" class="form-label">Categories</label>
<input type="text" class="form-control" id="categories" />
</div>
<hr class="divider" />
<div class="form-group">
<label for="keywords" class="form-label">Keywords</label>
<input type="text" class="form-control" id="keywords" />
</div>
</div>
</div>
</div>
</div>
<div class="d-flex gap-2 justify-content-end">
<button type="button" class="btn btn-dark border" id="publish">Publish</button>
<button type="button" class="btn btn-dark border" id="draft">Save as draft</button>
<button class="btn btn-light border" id="cancel">Cancel</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script>
var editor1 = new RichTextEditor("#tiny");
// let FeaturedImage = document.querySelector('#feature').value;
$("#cancel").on('click', function () {
location.href = "blog-list.html"
})
$("#draft").on('click', function () {
})
const fileInput = document.getElementById('file'); // Assuming you have an input with id="imageInput"
var featuredImage;
fileInput.addEventListener('change', function () {
const file = this.files[0]; // Get the first selected file
// You can now access file properties like:
console.log(file.name); // File name
console.log(file.size); // File size
console.log(file.type); // File type
// To preview the image, you can use FileReader:
const reader = new FileReader();
reader.onload = function (e) {
featuredImage = e.target.result;
const img = document.createElement('img');
$(img).addClass('img-fluid')
img.src = e.target.result;
$('#preview').html(img);
};
reader.readAsDataURL(file);
});
$("#publish").on('click', function () {
let titleOfBlog = document.querySelector('#blogTitle').value;
let author = document.querySelector('#author').value;
let categories = document.querySelector('#categories').value;
let keywords = document.querySelector('#keywords').value;
let summary = document.querySelector('#summary').value;
let metaTitle = document.querySelector('#meta-title').value;
let metaSummary = document.querySelector('#meta-summary').value;
// let FeaturedImage = document.('#file').files[0];
let content = editor1.getHTML();
fetch("/blogs", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
title: titleOfBlog,
author: author,
categories: categories,
meta_keywords: String(keywords).split(','),
expert: summary,
meta_title: metaTitle,
meta_description: metaSummary,
featured_image: featuredImage,
content: content,
status: "Publish",
slug: String(titleOfBlog).replaceAll(' ', '-'),
createdAt: new Date().toLocaleString()
})
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
});
})
</script>
</body>
</html>