Skip to content

Commit 69337a3

Browse files
committed
Improvments, some CSS + adding init and systemd examples
1 parent 80e4e58 commit 69337a3

23 files changed

+7889
-68
lines changed

INSTALL.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sudo apt-get install carton
2323
After installing Carton :
2424

2525
```shell
26-
git clone https://github.com/ldidry/padro.git
26+
git clone https://git.framasoft.org/luc/padro.git
2727
cd padro
2828
carton install
2929
cp padro.conf.template padro.conf
@@ -54,6 +54,8 @@ CREATE DATABASE minion;
5454
GRANT ALL PRIVILEGES ON DATABASE minion to minion_user;
5555
```
5656

57+
(Don't forget to update your `padro.conf` with the accurate database users and passwords)
58+
5759
## Starting Padro from command line
5860

5961
```
@@ -66,6 +68,31 @@ carton exec hypnotoad script/padro
6668
carton exec script/padro minion worker
6769
```
6870

71+
## Init script
72+
73+
```
74+
cp utilities/padro.init /etc/init.d/padro
75+
cp utilities/padro_minion.init /etc/init.d/padro_minion
76+
cp utilities/padro.default /etc/default/padro
77+
# Change PDIR to match your installation
78+
vi /etc/default/padro
79+
update-rc.d padro defaults
80+
update-rc.d padro_minion defaults
81+
```
82+
83+
**NB** The `padro_minion.init` may fail. In that case, start minion worker from the command line
84+
85+
## Systemd
86+
87+
```
88+
cp utilities/padro.service /etc/systemd/system/
89+
cp utilities/padro_minion.service /etc/systemd/system/
90+
# Change WorkingDirectory, PIDFile and the absolute path to carton to match your installation
91+
vi /etc/systemd/system/padro.service /etc/systemd/system/padro_minion.service
92+
systemctl enable padro.service
93+
systemctl enable padro_minion.service
94+
```
95+
6996
## Putting Padro behind a reverse proxy
7097

7198
Well, if you have an Etherpad instance to use with Padro, I guess you'll find a doc to put Padro behind a reverse proxy.

cpanfile.snapshot

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# carton snapshot format: version 1.0
22
DISTRIBUTIONS
3-
CPAN-Meta-2.143240
4-
pathname: D/DA/DAGOLDEN/CPAN-Meta-2.143240.tar.gz
5-
provides:
6-
CPAN::Meta 2.143240
7-
CPAN::Meta::Converter 2.143240
8-
CPAN::Meta::Feature 2.143240
9-
CPAN::Meta::History 2.143240
10-
CPAN::Meta::Merge 2.143240
11-
CPAN::Meta::Prereqs 2.143240
12-
CPAN::Meta::Spec 2.143240
13-
CPAN::Meta::Validator 2.143240
3+
CPAN-Meta-2.150001
4+
pathname: D/DA/DAGOLDEN/CPAN-Meta-2.150001.tar.gz
5+
provides:
6+
CPAN::Meta 2.150001
7+
CPAN::Meta::Converter 2.150001
8+
CPAN::Meta::Feature 2.150001
9+
CPAN::Meta::History 2.150001
10+
CPAN::Meta::Merge 2.150001
11+
CPAN::Meta::Prereqs 2.150001
12+
CPAN::Meta::Spec 2.150001
13+
CPAN::Meta::Validator 2.150001
1414
requirements:
1515
CPAN::Meta::Requirements 2.121
1616
CPAN::Meta::YAML 0.008
@@ -38,12 +38,12 @@ DISTRIBUTIONS
3838
perl 5.006
3939
strict 0
4040
warnings 0
41-
Class-MethodMaker-2.22
42-
pathname: S/SC/SCHWIGON/class-methodmaker/Class-MethodMaker-2.22.tar.gz
41+
Class-MethodMaker-2.23
42+
pathname: S/SC/SCHWIGON/class-methodmaker/Class-MethodMaker-2.23.tar.gz
4343
provides:
44-
Class::MethodMaker 2.22
44+
Class::MethodMaker 2.23
4545
Class::MethodMaker::Constants undef
46-
Class::MethodMaker::Engine 2.22
46+
Class::MethodMaker::Engine 2.23
4747
Class::MethodMaker::OptExt undef
4848
Class::MethodMaker::V1Compat undef
4949
Generate undef
@@ -211,16 +211,16 @@ DISTRIBUTIONS
211211
Encode::Alias 0
212212
ExtUtils::MakeMaker 0
213213
perl 5.008
214-
Etherpad-API-1.2.10.0
215-
pathname: L/LD/LDIDRY/Etherpad-API-1.2.10.0.tar.gz
214+
Etherpad-API-1.2.10.3
215+
pathname: L/LD/LDIDRY/Etherpad-API-1.2.10.3.tar.gz
216216
provides:
217-
Etherpad::API 1.002010000
217+
Etherpad::API 1.002010003
218218
requirements:
219219
ExtUtils::MakeMaker 0
220220
JSON::XS 0
221221
LWP::UserAgent 0
222222
Test::Simple 0.44
223-
URI::Escape 0
223+
URI::Encode 0
224224
File-Listing-6.04
225225
pathname: G/GA/GAAS/File-Listing-6.04.tar.gz
226226
provides:
@@ -354,12 +354,13 @@ DISTRIBUTIONS
354354
requirements:
355355
ExtUtils::MakeMaker 0
356356
perl 5.006002
357-
Minion-1.08
358-
pathname: S/SR/SRI/Minion-1.08.tar.gz
357+
Minion-1.10
358+
pathname: S/SR/SRI/Minion-1.10.tar.gz
359359
provides:
360-
Minion 1.08
360+
Minion 1.10
361361
Minion::Backend undef
362362
Minion::Backend::File undef
363+
Minion::Backend::File::_Guard undef
363364
Minion::Backend::Pg undef
364365
Minion::Command::minion undef
365366
Minion::Command::minion::job undef
@@ -370,7 +371,7 @@ DISTRIBUTIONS
370371
requirements:
371372
DBM::Deep 2.0011
372373
ExtUtils::MakeMaker 0
373-
Mojolicious 5.81
374+
Mojolicious 6.0
374375
Module-Build-0.4211
375376
pathname: L/LE/LEONT/Module-Build-0.4211.tar.gz
376377
provides:
@@ -421,10 +422,10 @@ DISTRIBUTIONS
421422
Text::ParseWords 0
422423
perl 5.008000
423424
version 0.87
424-
Mojo-Pg-1.10
425-
pathname: S/SR/SRI/Mojo-Pg-1.10.tar.gz
425+
Mojo-Pg-1.12
426+
pathname: S/SR/SRI/Mojo-Pg-1.12.tar.gz
426427
provides:
427-
Mojo::Pg 1.10
428+
Mojo::Pg 1.12
428429
Mojo::Pg::Database undef
429430
Mojo::Pg::Migrations undef
430431
Mojo::Pg::PubSub undef
@@ -433,9 +434,9 @@ DISTRIBUTIONS
433434
requirements:
434435
DBD::Pg 0
435436
ExtUtils::MakeMaker 0
436-
Mojolicious 5.81
437-
Mojolicious-5.82
438-
pathname: S/SR/SRI/Mojolicious-5.82.tar.gz
437+
Mojolicious 6.0
438+
Mojolicious-6.01
439+
pathname: S/SR/SRI/Mojolicious-6.01.tar.gz
439440
provides:
440441
Mojo undef
441442
Mojo::Asset undef
@@ -498,7 +499,7 @@ DISTRIBUTIONS
498499
Mojo::UserAgent::Server undef
499500
Mojo::UserAgent::Transactor undef
500501
Mojo::Util undef
501-
Mojolicious 5.82
502+
Mojolicious 6.01
502503
Mojolicious::Command undef
503504
Mojolicious::Command::cgi undef
504505
Mojolicious::Command::cpanify undef
@@ -670,17 +671,22 @@ DISTRIBUTIONS
670671
List::Util 1.09
671672
Scalar::Util 1.09
672673
Test::Builder 0
673-
Test-Exception-0.36
674-
pathname: E/EX/EXODIST/Test-Exception-0.36.tar.gz
674+
Test-Exception-0.38
675+
pathname: E/ET/ETHER/Test-Exception-0.38.tar.gz
675676
provides:
676-
Test::Exception 0.36
677+
Test::Exception 0.38
677678
requirements:
679+
Carp 0
680+
Exporter 0
681+
ExtUtils::MakeMaker 0
678682
Sub::Uplevel 0.18
679683
Test::Builder 0.7
680684
Test::Builder::Tester 1.07
681685
Test::Harness 2.03
682-
Test::More 0.7
683-
Test::Simple 0.7
686+
base 0
687+
perl 5.006001
688+
strict 0
689+
warnings 0
684690
Test-Warn-0.30
685691
pathname: C/CH/CHORNY/Test-Warn-0.30.tar.gz
686692
provides:
@@ -705,10 +711,10 @@ DISTRIBUTIONS
705711
requirements:
706712
ExtUtils::MakeMaker 0
707713
common::sense 0
708-
URI-1.65
709-
pathname: E/ET/ETHER/URI-1.65.tar.gz
714+
URI-1.67
715+
pathname: E/ET/ETHER/URI-1.67.tar.gz
710716
provides:
711-
URI 1.65
717+
URI 1.67
712718
URI::Escape 3.31
713719
URI::Heuristic 4.20
714720
URI::IRI undef
@@ -719,14 +725,14 @@ DISTRIBUTIONS
719725
URI::_foreign undef
720726
URI::_generic undef
721727
URI::_idna undef
722-
URI::_ldap 1.65
728+
URI::_ldap 1.67
723729
URI::_login undef
724-
URI::_punycode 1.65
730+
URI::_punycode 1.67
725731
URI::_query undef
726732
URI::_segment undef
727733
URI::_server undef
728734
URI::_userpass undef
729-
URI::data 1.65
735+
URI::data 1.67
730736
URI::file 4.21
731737
URI::file::Base undef
732738
URI::file::FAT undef
@@ -739,7 +745,7 @@ DISTRIBUTIONS
739745
URI::gopher undef
740746
URI::http undef
741747
URI::https undef
742-
URI::ldap 1.65
748+
URI::ldap 1.67
743749
URI::ldapi undef
744750
URI::ldaps undef
745751
URI::mailto undef
@@ -751,7 +757,7 @@ DISTRIBUTIONS
751757
URI::rsync undef
752758
URI::rtsp undef
753759
URI::rtspu undef
754-
URI::sip 1.65
760+
URI::sip 1.67
755761
URI::sips undef
756762
URI::snews undef
757763
URI::ssh undef
@@ -768,6 +774,16 @@ DISTRIBUTIONS
768774
parent 0
769775
perl 5.008001
770776
utf8 0
777+
URI-Encode-v1.0.1
778+
pathname: M/MI/MITHUN/URI-Encode-v1.0.1.tar.gz
779+
provides:
780+
URI::Encode 1.000001
781+
requirements:
782+
Encode 2.12
783+
Module::Build 0.38
784+
Test::More 0
785+
perl v5.8.1
786+
version 0
771787
WWW-RobotRules-6.02
772788
pathname: G/GA/GAAS/WWW-RobotRules-6.02.tar.gz
773789
provides:

lib/Padro.pm

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ sub startup {
6868
my $results = $db->query('SELECT * FROM pads WHERE name = (?)', $name);
6969

7070
if ($results->rows == 1) {
71-
return $results->hash;
71+
my $r = $db->query('select authors.name from authors JOIN pad_has_authors ON authors.ep_id = pad_has_authors.author_id WHERE pad_has_authors.pad_id = (?) ORDER BY authors.name', $name);
72+
my $pad = $results->hash;
73+
$pad->{authors} = $r->hashes if ($r->rows > 0);
74+
return $pad;
7275
} elsif ($results->rows > 1) {
7376
$c->app->log->error('More than one row returned when looking for a pad, this is not supposed to happen!');
7477

75-
return undef;
76-
} elsif ($counter > 1) {
77-
$c->app->log->error('There\'s a problem while fetching '.$name);
78-
7978
return undef;
8079
} else {
8180
my $ep = $c->app->ep;
@@ -88,12 +87,14 @@ sub startup {
8887

8988
my $text = $ep->get_text($name);
9089
my $html = $ep->get_html($name);
91-
my ($s, $m, $h, $day, $month, $year) = gmtime($ep->get_last_edited($name));
90+
my $time = $ep->get_last_edited($name);
91+
$time =~ s/\d{3}$//;
92+
my ($s, $m, $h, $day, $month, $year) = gmtime($time);
9293
my $last_edition = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $year + 1900, $month + 1, $day, $h, $m, $s);
9394

94-
my $r = $db->query('INSERT INTO pads (name, text, html, revisions, last_edition) VALUES (?, ?, ?, ?, ?)', ($name, $text, $html, $revisions, $last_edition));
95+
my $r = $db->query('INSERT INTO pads (name, text, html, revisions, last_edition) VALUES (?, ?, ?, ?, ?) RETURNING *', ($name, $text, $html, $revisions, $last_edition));
9596

96-
return $c->find_or_fetch($name, ++$counter);
97+
return $r->hash;
9798
}
9899
}
99100
);
@@ -153,7 +154,9 @@ sub startup {
153154

154155
my $text = $ep->get_text($name);
155156
my $html = $ep->get_html($name);
156-
my ($s, $m, $h, $day, $month, $year) = gmtime($ep->get_last_edited($name));
157+
my $time = $ep->get_last_edited($name);
158+
$time =~ s/\d{3}$//;
159+
my ($s, $m, $h, $day, $month, $year) = gmtime($time);
157160
my $last_edition = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $year + 1900, $month + 1, $day, $h, $m, $s);
158161

159162
my $r = $job->app->pg->db->query('INSERT INTO pads (name, text, html, revisions, last_edition) VALUES (?, ?, ?, ?, ?)', ($name, $text, $html, $revisions, $last_edition));
@@ -162,10 +165,13 @@ sub startup {
162165

163166
# Database migration
164167
my $migrations = Mojo::Pg::Migrations->new(pg => $self->pg);
165-
#$migrations->from_file('migrations.sql')->migrate(0)->migrate(1);
166-
$migrations->from_file('migrations.sql')->migrate(1);
168+
if ($self->mode eq 'development') {
169+
$migrations->from_file('migrations.sql')->migrate(0)->migrate(1);
170+
$self->app->minion->reset;
171+
} else {
172+
$migrations->from_file('migrations.sql')->migrate(1);
173+
}
167174

168-
#$self->app->minion->reset;
169175

170176
# Router
171177
my $r = $self->routes;

padro.conf.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
# Optional: user and password
4040
# user => 'ep_user',
4141
# password => 'ep_password'
42+
# Optional: web proxy settings
43+
# proxy => {
44+
# http => 'http://my_web_proxy_url:my_web_proxy_port',
45+
# https => 'http://my_web_proxy_url:my_web_proxy_port',
46+
# }
4247
},
4348
##########################
4449
# Minion database settings

0 commit comments

Comments
 (0)