-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite.php
executable file
·210 lines (184 loc) · 8.31 KB
/
write.php
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
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
session_start();
if(!isset($_SESSION['userId'])){
header("Location: login.php");
}
spl_autoload_register(function($name){
$name = strtolower($name);
require_once(getcwd()."/logic/classes/$name.class.php");
});
if(isset($_GET['id']) && (int)$_GET['id'] !== 0){
$article = new Article($_GET['id']);
$articleId = $article->getId();
}else{
require_once "logic/procedures/addArticle.php";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Newsreader:wght@300;400;600;700&display=swap"
rel="stylesheet"
/>
<link
rel="icon"
href="assets/img/logo.svg"
type="image/svg"
sizes="16x16"
/>
<link rel="stylesheet" href="./assets/css/style.css" />
<script
src="https://kit.fontawesome.com/1239ccb1ec.js"
crossorigin="anonymous"
></script>
<title>Pangaea</title>
</head>
<body>
<!-- html files will be injected into the divs defined here-->
<div id="navbar"></div>
<div class="flex flex-col">
<div
id = "loaderContainer"
class="flex lg:sticky lg:top-0 flex-row justify-end w-full mt-3 py-6 px-6 sm:px-36"
>
<div class="hidden" id="loader">
<div class="flex flex-row items-center">
<img src="assets/img/grid.svg" width="16" alt="..." class="mr-3">
<p class="text-gray-500">Saving</p>
</div>
</div>
<div>
<button
class="trigger rounded text-white bg-blue-500 py-2 px-4 text-xs font-bold"
>
Publish
</button>
</div>
</div>
<div class="mt-3 flex flex-col">
<div
class="w-full sm:w-6/12 sm:mx-auto p-6 flex flex-col items-center"
>
<div class="w-full mb-3">
<span
id="title_label"
class="text-xs font-bold text-gray-500 hidden"
>Title</span
>
<input
type="text"
name="title"
id="title"
class="font-serif text-lg w-full py-2 px-4 focus:outline-none focus:ring-2 focus:ring-blue-200 rounded"
placeholder="Title"
value="<?php echo isset($article)?$article->getTitle(): ""; ?>"
/>
</div>
<div class="w-full">
<span
id="subtitle_label"
class="text-xs font-bold text-gray-500 hidden"
>Subtitle</span
>
<input
type="text"
name="subtitle"
id="subtitle"
class="font-serif text-lg w-full py-2 px-4 focus:outline-none focus:ring-2 focus:ring-blue-200 rounded"
placeholder="Subtitle"
value="<?php echo isset($article)?$article->getSubtitle(): ""; ?>"
/>
</div>
</div>
<div
id="editorjs"
class="w-full shadow-sm border rounded sm:w-8/12 sm:mx-auto p-6 font-serif text-lg prose lg:prose-xl"
></div>
</div>
</div>
<input type="text" name="user-id" id="user-id" value="<?php echo $_SESSION['userId'] ?>" hidden>
<input type="text" name="article-id" id="article-id" value="<?php echo $articleId ?>" hidden>
<?php
if(isset($article)){
echo "<input type=\"text\" name=\"article-id\" id=\"article-id\" value=\"{$article->getBody()}\" hidden>";
}
?>
<!-- Modal -->
<div class="modal">
<div
class="modal-content flex flex-col sm:flex bg-gray-50 rounded-md w-10/12 sm:w-6/12 sm:mx-auto sm:mt-6 shadow mb-10"
>
<!--Header-->
<div class="flex justify-between p-2 items-center">
<div class="m-2 py-1 px-2 text-gray-500 text-lg">Add tags to your article</div>
<div class="flex justify-center items-center rounded-full hover:bg-gray-200 m-2 p-2">
<span class="text-gray-500 close-button flex justify-center items-center my-auto">×</span>
</div>
</div>
<div class="m-2">
<!--Input-->
<div class="text-sm text-gray-500 py-2 px-4 relative flex justify-start">
<input
type="text"
name="tag"
id="tag"
class="text-gray-500 py-2 px-4 rounded-3xl border focus:outline-none w-2/3"
placeholder="Enter tags here"
/>
<div class="rounded w-1/2 hidden absolute top-12 left-6 py-2 border shadow z-50 bg-white overflow-y-hidden" id="suggestions">
<ul id="suggested-tags-list" class="overflow-y-scroll h-48">
</ul>
</div>
</div>
<div class="flex flex-col md:flex-wrap md:flex-row md:items-center p-6 w-full" id="tags">
</div>
<!--Checkbox-->
<div
class="text-xs max-w-none text-gray-500 text-justify flex items-start p-6"
>
<input
type="checkbox"
name="permission"
id="permission"
value="Granted"
/>
<label for="permission" class="ml-2"
>Allow Pangaea curators to curate my article to reach a
bigger audience. Without checking this your article
won’t earn money.</label
>
</div>
<!--Button-->
<div class="flex justify-end m-2">
<button
id="go-live"
class="flex rounded text-white bg-blue-500 py-2 px-4 text-xs font-bold"
>
<img src="assets/img/grid2.svg" id="publish-loader" class="hidden mr-2" width="12" alt="..." class="mr-3">Go Live
</button>
</div>
</div>
</div>
</div>
<!-- JS file injections-->
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/paragraph@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/simple-image@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/embed@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/delimiter@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/image@2.3.0"></script>
<script src="./assets/js/write.js"></script>
<script src="./assets/js/parser.js"></script>
</body>
</html>