|
@@ -16,12 +16,14 @@ page_form::page_form(apps::wiki *_w):
|
16
|
16
|
{
|
17
|
17
|
title.message(_("Title"));
|
18
|
18
|
content.message(_("Content"));
|
|
19
|
+ pad_url.message(_("Pad URL"));
|
19
|
20
|
sidebar.message(_("Sidebar"));
|
20
|
21
|
save.value(_("Save"));
|
21
|
22
|
save_cont.value(_("Save and Continue"));
|
22
|
23
|
preview.value(_("Preview"));
|
23
|
24
|
fields.add(title);
|
24
|
25
|
fields.add(content);
|
|
26
|
+ fields.add(pad_url);
|
25
|
27
|
fields.add(sidebar);
|
26
|
28
|
buttons.add(save);
|
27
|
29
|
buttons.add(save_cont);
|
|
@@ -32,7 +34,6 @@ page_form::page_form(apps::wiki *_w):
|
32
|
34
|
users_only.help(_("Disable editing by visitors"));
|
33
|
35
|
users_only.error_message(_("Please Login"));
|
34
|
36
|
title.non_empty();
|
35
|
|
- content.non_empty();
|
36
|
37
|
content.rows(25);
|
37
|
38
|
content.cols(60);
|
38
|
39
|
sidebar.rows(10);
|
|
@@ -113,20 +114,20 @@ void page::diff(std::string slug,std::string sv1,std::string sv2)
|
113
|
114
|
c.v2=v2;
|
114
|
115
|
c.edit_v1=edit_version_url(v1);
|
115
|
116
|
c.edit_v2=edit_version_url(v2);
|
116
|
|
- r=sql<< "SELECT version,history.title,history.content,history.sidebar,pages.title FROM pages "
|
|
117
|
+ r=sql<< "SELECT version,history.title,history.content,history.pad_url,history.sidebar,pages.title FROM pages "
|
117
|
118
|
"JOIN history ON pages.id=history.id "
|
118
|
119
|
"WHERE lang=? AND slug=? AND version IN (?,?) " << locale_name << slug << v1 << v2;
|
119
|
120
|
|
120
|
|
- std::string t1,c1,s1,t2,c2,s2;
|
|
121
|
+ std::string t1,c1,p1,s1,t2,c2,p2,s2;
|
121
|
122
|
int count=0;
|
122
|
123
|
while(r.next()) {
|
123
|
124
|
int ver;
|
124
|
125
|
r>>ver;
|
125
|
126
|
if(ver==v1) {
|
126
|
|
- r>>t1>>c1>>s1>>c.title;
|
|
127
|
+ r>>t1>>c1>>p2>>s1>>c.title;
|
127
|
128
|
}
|
128
|
129
|
else {
|
129
|
|
- r>>t2>>c2>>s2;
|
|
130
|
+ r>>t2>>c2>>p2>>s2;
|
130
|
131
|
}
|
131
|
132
|
count++;
|
132
|
133
|
}
|
|
@@ -150,13 +151,19 @@ void page::diff(std::string slug,std::string sv1,std::string sv2)
|
150
|
151
|
std::vector<std::string> Y=split(c2);
|
151
|
152
|
diff::diff(X,Y,c.content_diff_content);
|
152
|
153
|
}
|
|
154
|
+ if(p1!=p2) {
|
|
155
|
+ c.pad_url_diff=true;
|
|
156
|
+ std::vector<std::string> X=split(p1);
|
|
157
|
+ std::vector<std::string> Y=split(p2);
|
|
158
|
+ diff::diff(X,Y,c.pad_url_diff_content);
|
|
159
|
+ }
|
153
|
160
|
if(s1!=s2) {
|
154
|
161
|
c.sidebar_diff=true;
|
155
|
162
|
std::vector<std::string> X=split(s1);
|
156
|
163
|
std::vector<std::string> Y=split(s2);
|
157
|
164
|
diff::diff(X,Y,c.sidebar_diff_content);
|
158
|
165
|
}
|
159
|
|
- if(t1==t2 && c1==c2 && s1==s2)
|
|
166
|
+ if(t1==t2 && c1==c2 && p1==p2 && s1==s2)
|
160
|
167
|
c.no_diff=true;
|
161
|
168
|
master::ini(c);
|
162
|
169
|
render("diff",c);
|
|
@@ -218,8 +225,8 @@ void page::display(std::string slug)
|
218
|
225
|
{
|
219
|
226
|
this->slug=slug;
|
220
|
227
|
std::string key="article_"+locale_name+":"+slug;
|
221
|
|
- if(cache().fetch_page(key))
|
222
|
|
- return;
|
|
228
|
+ // if(cache().fetch_page(key))
|
|
229
|
+ // return;
|
223
|
230
|
content::page c;
|
224
|
231
|
|
225
|
232
|
cppdb::session sql(conn);
|
|
@@ -282,14 +289,15 @@ bool page::load(content::page_form &form)
|
282
|
289
|
{
|
283
|
290
|
cppdb::session sql(conn);
|
284
|
291
|
cppdb::result r;
|
285
|
|
- r=sql<< "SELECT title,content,sidebar,users_only "
|
|
292
|
+ r=sql<< "SELECT title,content,pad_url,sidebar,users_only "
|
286
|
293
|
"FROM pages WHERE lang=? AND slug=?" << locale_name << slug << cppdb::row;
|
287
|
294
|
if(!r.empty()) {
|
288
|
|
- std::string title,content,sidebar;
|
|
295
|
+ std::string title,content,pad_url,sidebar;
|
289
|
296
|
int users_only;
|
290
|
|
- r >> title >> content >> sidebar >> users_only;
|
|
297
|
+ r >> title >> content >> pad_url >> sidebar >> users_only;
|
291
|
298
|
form.title.value(title);
|
292
|
299
|
form.content.value(content);
|
|
300
|
+ form.pad_url.value(pad_url);
|
293
|
301
|
form.sidebar.value(sidebar);
|
294
|
302
|
form.users_only.value(users_only);
|
295
|
303
|
return true;
|
|
@@ -310,31 +318,33 @@ void page::save(int id,content::page_form &form,cppdb::session &sql)
|
310
|
318
|
std::tm t = booster::ptime::local_time(booster::ptime::now());
|
311
|
319
|
wi.users.auth();
|
312
|
320
|
if(id!=-1) {
|
313
|
|
- sql<< "UPDATE pages SET content=?,title=?,sidebar=?,users_only=? "
|
|
321
|
+ sql<< "UPDATE pages SET content=?,title=?,pad_url=?,sidebar=?,users_only=? "
|
314
|
322
|
"WHERE lang=? AND slug=?"
|
315
|
|
- << form.content.value() << form.title.value()
|
|
323
|
+ << form.content.value() << form.title.value() << form.pad_url.value()
|
316
|
324
|
<< form.sidebar.value() << form.users_only.value()
|
317
|
325
|
<< locale_name << slug << cppdb::exec;
|
318
|
326
|
}
|
319
|
327
|
else {
|
320
|
328
|
cppdb::statement s;
|
321
|
|
- s=sql<< "INSERT INTO pages(lang,slug,title,content,sidebar,users_only) "
|
322
|
|
- "VALUES(?,?,?,?,?,?)"
|
|
329
|
+ s=sql<< "INSERT INTO pages(lang,slug,title,content,pad_url,sidebar,users_only) "
|
|
330
|
+ "VALUES(?,?,?,?,?,?,?)"
|
323
|
331
|
<< locale_name << slug
|
324
|
332
|
<< form.title.value()
|
325
|
333
|
<< form.content.value()
|
|
334
|
+ << form.pad_url.value()
|
326
|
335
|
<< form.sidebar.value()
|
327
|
336
|
<< form.users_only.value();
|
328
|
337
|
s.exec();
|
329
|
338
|
id=s.sequence_last("pages_id_seq");
|
330
|
339
|
}
|
331
|
|
- sql<< "INSERT INTO history(id,version,created,title,content,sidebar,author) "
|
|
340
|
+ sql<< "INSERT INTO history(id,version,created,title,content,pad_url,sidebar,author) "
|
332
|
341
|
"SELECT ?,"
|
333
|
342
|
" (SELECT COALESCE(MAX(version),0)+1 FROM history WHERE id=?),"
|
334
|
|
- " ?,?,?,?,?"
|
|
343
|
+ " ?,?,?,?,?,?"
|
335
|
344
|
<< id << id << t
|
336
|
345
|
<< form.title.value()
|
337
|
346
|
<< form.content.value()
|
|
347
|
+ << form.pad_url.value()
|
338
|
348
|
<< form.sidebar.value()
|
339
|
349
|
<< wi.users.username
|
340
|
350
|
<< cppdb::exec;
|
|
@@ -373,6 +383,7 @@ bool page::edit_on_post(content::edit_page &c)
|
373
|
383
|
if(c.form.preview.value()) {
|
374
|
384
|
c.title=c.form.title.value();
|
375
|
385
|
c.content=c.form.content.value();
|
|
386
|
+ c.pad_url=c.form.pad_url.value();
|
376
|
387
|
c.sidebar=c.form.sidebar.value();
|
377
|
388
|
}
|
378
|
389
|
}
|
|
@@ -384,17 +395,18 @@ bool page::load_history(int ver,content::page_form &form)
|
384
|
395
|
{
|
385
|
396
|
cppdb::session sql(conn);
|
386
|
397
|
cppdb::result r;
|
387
|
|
- r=sql<< "SELECT history.title,history.content,history.sidebar,pages.users_only "
|
|
398
|
+ r=sql<< "SELECT history.title,history.content,history.pad_url,history.sidebar,pages.users_only "
|
388
|
399
|
"FROM pages "
|
389
|
400
|
"JOIN history ON pages.id=history.id "
|
390
|
401
|
"WHERE pages.lang=? AND pages.slug=? AND history.version=?"
|
391
|
402
|
<<locale_name<<slug<<ver<<cppdb::row;
|
392
|
403
|
if(!r.empty()) {
|
393
|
|
- std::string title,content,sidebar;
|
|
404
|
+ std::string title,content,pad_url,sidebar;
|
394
|
405
|
int uonly;
|
395
|
|
- r >> title >> content >> sidebar >> uonly;
|
|
406
|
+ r >> title >> content >> pad_url >> sidebar >> uonly;
|
396
|
407
|
form.title.value(title);
|
397
|
408
|
form.content.value(content);
|
|
409
|
+ form.pad_url.value(pad_url);
|
398
|
410
|
form.sidebar.value(sidebar);
|
399
|
411
|
form.users_only.value(uonly);
|
400
|
412
|
return true;
|
|
@@ -409,7 +421,7 @@ void page::display_ver(std::string slug,std::string sid)
|
409
|
421
|
int id=atoi(sid.c_str());
|
410
|
422
|
cppdb::result r;
|
411
|
423
|
cppdb::session sql(conn);
|
412
|
|
- r=sql<< "SELECT history.title,history.content,history.sidebar,history.created "
|
|
424
|
+ r=sql<< "SELECT history.title,history.content,history.pad_url,history.sidebar,history.created "
|
413
|
425
|
"FROM pages "
|
414
|
426
|
"JOIN history ON pages.id=history.id "
|
415
|
427
|
"WHERE pages.lang=? AND pages.slug=? AND history.version=?"
|