|
@@ -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);
|
|
@@ -282,7 +289,7 @@ 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
|
295
|
std::string title,content,sidebar;
|
|
@@ -310,31 +317,33 @@ void page::save(int id,content::page_form &form,cppdb::session &sql)
|
310
|
317
|
std::tm t = booster::ptime::local_time(booster::ptime::now());
|
311
|
318
|
wi.users.auth();
|
312
|
319
|
if(id!=-1) {
|
313
|
|
- sql<< "UPDATE pages SET content=?,title=?,sidebar=?,users_only=? "
|
|
320
|
+ sql<< "UPDATE pages SET content=?,title=?,pad_url=?,sidebar=?,users_only=? "
|
314
|
321
|
"WHERE lang=? AND slug=?"
|
315
|
|
- << form.content.value() << form.title.value()
|
|
322
|
+ << form.content.value() << form.title.value() << form.pad_url.value()
|
316
|
323
|
<< form.sidebar.value() << form.users_only.value()
|
317
|
324
|
<< locale_name << slug << cppdb::exec;
|
318
|
325
|
}
|
319
|
326
|
else {
|
320
|
327
|
cppdb::statement s;
|
321
|
|
- s=sql<< "INSERT INTO pages(lang,slug,title,content,sidebar,users_only) "
|
322
|
|
- "VALUES(?,?,?,?,?,?)"
|
|
328
|
+ s=sql<< "INSERT INTO pages(lang,slug,title,content,pad_url,sidebar,users_only) "
|
|
329
|
+ "VALUES(?,?,?,?,?,?,?)"
|
323
|
330
|
<< locale_name << slug
|
324
|
331
|
<< form.title.value()
|
325
|
332
|
<< form.content.value()
|
|
333
|
+ << form.pad_url.value()
|
326
|
334
|
<< form.sidebar.value()
|
327
|
335
|
<< form.users_only.value();
|
328
|
336
|
s.exec();
|
329
|
337
|
id=s.sequence_last("pages_id_seq");
|
330
|
338
|
}
|
331
|
|
- sql<< "INSERT INTO history(id,version,created,title,content,sidebar,author) "
|
|
339
|
+ sql<< "INSERT INTO history(id,version,created,title,content,pad_url,sidebar,author) "
|
332
|
340
|
"SELECT ?,"
|
333
|
341
|
" (SELECT COALESCE(MAX(version),0)+1 FROM history WHERE id=?),"
|
334
|
|
- " ?,?,?,?,?"
|
|
342
|
+ " ?,?,?,?,?,?"
|
335
|
343
|
<< id << id << t
|
336
|
344
|
<< form.title.value()
|
337
|
345
|
<< form.content.value()
|
|
346
|
+ << form.pad_url.value()
|
338
|
347
|
<< form.sidebar.value()
|
339
|
348
|
<< wi.users.username
|
340
|
349
|
<< cppdb::exec;
|
|
@@ -373,6 +382,7 @@ bool page::edit_on_post(content::edit_page &c)
|
373
|
382
|
if(c.form.preview.value()) {
|
374
|
383
|
c.title=c.form.title.value();
|
375
|
384
|
c.content=c.form.content.value();
|
|
385
|
+ c.pad_url=c.form.pad_url.value();
|
376
|
386
|
c.sidebar=c.form.sidebar.value();
|
377
|
387
|
}
|
378
|
388
|
}
|
|
@@ -384,17 +394,18 @@ bool page::load_history(int ver,content::page_form &form)
|
384
|
394
|
{
|
385
|
395
|
cppdb::session sql(conn);
|
386
|
396
|
cppdb::result r;
|
387
|
|
- r=sql<< "SELECT history.title,history.content,history.sidebar,pages.users_only "
|
|
397
|
+ r=sql<< "SELECT history.title,history.content,history.pad_url,history.sidebar,pages.users_only "
|
388
|
398
|
"FROM pages "
|
389
|
399
|
"JOIN history ON pages.id=history.id "
|
390
|
400
|
"WHERE pages.lang=? AND pages.slug=? AND history.version=?"
|
391
|
401
|
<<locale_name<<slug<<ver<<cppdb::row;
|
392
|
402
|
if(!r.empty()) {
|
393
|
|
- std::string title,content,sidebar;
|
|
403
|
+ std::string title,content,pad_url,sidebar;
|
394
|
404
|
int uonly;
|
395
|
|
- r >> title >> content >> sidebar >> uonly;
|
|
405
|
+ r >> title >> content >> pad_url >> sidebar >> uonly;
|
396
|
406
|
form.title.value(title);
|
397
|
407
|
form.content.value(content);
|
|
408
|
+ form.pad_url.value(pad_url);
|
398
|
409
|
form.sidebar.value(sidebar);
|
399
|
410
|
form.users_only.value(uonly);
|
400
|
411
|
return true;
|
|
@@ -409,7 +420,7 @@ void page::display_ver(std::string slug,std::string sid)
|
409
|
420
|
int id=atoi(sid.c_str());
|
410
|
421
|
cppdb::result r;
|
411
|
422
|
cppdb::session sql(conn);
|
412
|
|
- r=sql<< "SELECT history.title,history.content,history.sidebar,history.created "
|
|
423
|
+ r=sql<< "SELECT history.title,history.content,history.pad_url,history.sidebar,history.created "
|
413
|
424
|
"FROM pages "
|
414
|
425
|
"JOIN history ON pages.id=history.id "
|
415
|
426
|
"WHERE pages.lang=? AND pages.slug=? AND history.version=?"
|