Permalink
Browse files

Merge branch 'release/v0.20'

  • Loading branch information...
2 parents 23eb67b + 633fbc6 commit e79ae82b2c64ad31f1c7703ae381f45e03a7b37c @szabgab committed Oct 25, 2011
Showing with 4,572 additions and 561 deletions.
  1. +4 −0 .gitignore
  2. +14 −0 Changes
  3. +6 −0 Makefile.PL
  4. +11 −41 README
  5. +113 −8 lib/Dwimmer.pm
  6. +368 −14 lib/Dwimmer/Admin.pm
  7. +45 −72 lib/Dwimmer/Client.pm
  8. +0 −6 lib/Dwimmer/Client/Weekly.pm
  9. +96 −0 lib/Dwimmer/DB/Result/Feed.pm
  10. +98 −0 lib/Dwimmer/DB/Result/FeedCollector.pm
  11. +130 −0 lib/Dwimmer/DB/Result/MailingList.pm
  12. +106 −0 lib/Dwimmer/DB/Result/MailingListMember.pm
  13. +65 −0 lib/Dwimmer/DB/Result/SiteConfig.pm
  14. +374 −0 lib/Dwimmer/DB/Result/User.pm
  15. +15 −2 lib/Dwimmer/Tools.pm
  16. +71 −0 polls/perl-news.json
  17. +2 −2 public/404.html
  18. +2 −2 public/500.html
  19. +18 −0 public/css/style.css
  20. BIN public/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
  21. BIN public/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
  22. BIN public/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
  23. BIN public/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
  24. BIN public/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
  25. BIN public/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
  26. BIN public/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
  27. BIN public/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
  28. BIN public/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
  29. BIN public/css/ui-lightness/images/ui-icons_222222_256x240.png
  30. BIN public/css/ui-lightness/images/ui-icons_228ef1_256x240.png
  31. BIN public/css/ui-lightness/images/ui-icons_ef8c08_256x240.png
  32. BIN public/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
  33. BIN public/css/ui-lightness/images/ui-icons_ffffff_256x240.png
  34. +568 −0 public/css/ui-lightness/jquery-ui-1.8.16.custom.css
  35. +436 −279 public/javascripts/dwimmer.js
  36. +791 −0 public/javascripts/jquery-ui-1.8.16.custom.min.js
  37. +43 −0 public/javascripts/jquery.a-tools-1.5.2.min.js
  38. +52 −0 schema/1.sql
  39. +2 −1 schema/dwimmer.sql
  40. +1 −1 script/dwimmer
  41. +41 −0 script/dwimmer_backup.pl
  42. +52 −12 script/dwimmer_setup.pl
  43. +99 −0 script/feed_collector.pl
  44. +35 −16 t/003_client.t
  45. +6 −6 t/004_more.t
  46. +268 −10 t/010_weekly.t
  47. +83 −0 t/011_feed_collector.t
  48. +38 −5 t/014_new_site.t
  49. +91 −0 t/015_polls.t
  50. +115 −0 t/files/perl-mongers.json
  51. +63 −0 t/files/testing-polls.json
  52. +16 −2 t/lib/Dwimmer/Test.pm
  53. +11 −0 views/error.tt
  54. +6 −0 views/layouts/getclicky.tt
  55. +11 −0 views/layouts/google_analytics.tt
  56. +152 −82 views/layouts/main.tt
  57. +54 −0 views/poll.tt
View
@@ -5,6 +5,7 @@ blib
pm_to_blib
MANIFEST
MANIFEST.bak
+MYMETA.yml
META.yml
META.json
/inc
@@ -13,6 +14,9 @@ sessions
logs
/db
/share
+#/polls
+/polls/*.txt
+/polls/perl-mongers.json
SETUP.bat
Dwimmer-*
View
14 Changes
@@ -1,8 +1,22 @@
+v0.20 2011.10.25
+
+ Add jquery.a-tools-1.5.2 plugin.
+ Add B(old) and I(talic) buttons to editor.
+ Add jquery-ui-1.8.16.custom.min.js
+
+ Enable [http://address] and [https://address].
Add script/dwimmer to enable adding user from the command line.
Enable some special characters in the filename: space ( ), dot (.), $, @ and %.
Eliminate cache from the Ajax get requests as IE (both 8 and 9) would cache by default.
+ Replace several methods in the Dwimmer::Client or change their APIs
+ most importantly 'login', 'get_page',
+ Add site_config table
+ Add Google Analytics and GetClicky
+
+ Probably lots of other things I forgot to add to the Changes file.
+
v0.11 2011.09.10
Release of the first interesting version.
View
@@ -27,16 +27,21 @@ my %prereq = (
'DBIx::Class::Schema' => 0,
'DBIx::RunSQL' => 0,
'Email::Valid' => 0,
+ 'Encode' => 0,
'File::ShareDir' => '1.00',
'File::Slurp' => 0,
'Getopt::Long' => 0,
+ 'JSON' => 0,
'MIME::Lite' => 0,
+ 'Moose' => 0,
'Pod::Usage' => 0,
'String::Random' => 0,
'Template' => 0,
+ 'XML::Feed' => 0,
'XML::RSS' => 0,
'YAML' => 0,
);
+
if ($^O =~ /win32/i) {
$prereq{'Win32::Process'} = 0;
}
@@ -55,6 +60,7 @@ bugtracker 'http://github.com/szabgab/dwimmer';
repository 'http://github.com/szabgab/dwimmer';
install_script 'script/dwimmer_setup.pl';
+install_script 'script/dwimmer_backup.pl';
install_script 'script/dwimmer';
# Copy files to share before installing (but it is not included in the distribution)
View
52 README
@@ -1,29 +1,20 @@
+Dwimmer is an experiment.
-Stand alone installation:
-- Install everyting
-- Run database creation script that will ask for admin password
-
-
+It started as a blog engine with this screencast: http://www.youtube.com/watch?v=NGX5pgKWVoc
+but since then it is all kinds of things.
-TODO before minimal usability as in-house wiki
-==============================================
-- Restrict html to minimal interesting
-- Landing on a page that does not exist yet? show error OK
- (if the referer is internal and if user is logged it offer creation?. otherwise just show error?)
-- Show diff ???
-- Set older version to be the newest
-- allow only lowercase usernames or at least make them unique in a case insensitive way
+For example it is a wiki, a CMS, a planet...
+or a beginnnig of either of those.
+Mostly it is an experiment to write some stuff.
-TODO - personal one page editor
-================================
+=================================================
+Some notes:
-
-TODO: Misc
-===============
-- allow each user to write free text in a profile.
-- add multiple e-mail addresses
+Stand alone installation:
+- Install everyting
+- Run database creation script that will ask for admin password
TODO: Authorization
@@ -57,22 +48,6 @@ TODO Weekly
- Admin can add users without confirmation
- Admin can import CSV File?
-- User can register:
- e-mail, name (optional), send confirmation e-mail with code, allow the confirmation
- Unsubscribe: type in e-mail, send unsubscribe confirmation e-mail with code, allow the confirmation
-
-
-
-TODO From the web interface
-=======================
-- Configure email sending (local delivery or using an SMTP server)
-- Admin can add user
-- Move all the dwimmer pages to be under /_dwimmer/
-- Allow creating and editing of pages.
- each page should have
- 1) body text
- 2) list of comma separated tags
- 3) title
Markup language
=====================
@@ -86,15 +61,10 @@ Markup language
display this info and if the user is logged in then offer the page
to be edited/created.
-
- From the web site allow the creation of a site with basic usage.
- At first only the admin can create sites but later we might allow
regular users as well to create sites using the main site.
-
-Allow the admin to disable a user or even to delete it? Or we rather keep the user around for accounting purposes.
-
-
Sources:
JQuery http://jquery.com/
http://www.scriptbreaker.com/javascript/script/JQuery-Drop-down-panel-menu
View
@@ -3,17 +3,36 @@ use Dancer ':syntax';
use 5.008005;
-our $VERSION = '0.1101';
+our $VERSION = '0.20';
+use Data::Dumper qw(Dumper);
use Dwimmer::DB;
-use Dwimmer::Tools qw(_get_db _get_site);
+use Dwimmer::Tools qw(_get_db _get_site read_file $SCHEMA_VERSION);
+
+use Fcntl qw(:flock);
+use Template;
load_app 'Dwimmer::Admin', prefix => "/_dwimmer";
-
-my %open = map { $_ => 1 } qw(/_dwimmer/login.json /_dwimmer/session.json);
+
+# list of pages that can be accessed withot any login
+my %open = map { $_ => 1 } qw(
+ /poll
+ /_dwimmer/login.json
+ /_dwimmer/session.json
+ /_dwimmer/register_email.json /_dwimmer/register_email
+ /_dwimmer/validate_email.json /_dwimmer/validate_email
+);
hook before => sub {
my $path = request->path_info;
+
+ my $db = _get_db();
+ my ($version) = $db->storage->dbh->selectrow_array('PRAGMA user_version');
+ #see also do_dbh https://metacpan.org/module/DBIx::Class::Storage::DBI#dbh_do
+ if ($version != $SCHEMA_VERSION) {
+ return halt("Database is currently at version $version while we need version $SCHEMA_VERSION");
+ }
+
return if $open{$path};
return if $path !~ m{/_}; # only the pages starting with /_ are management pages that need restriction
@@ -27,22 +46,107 @@ hook before => sub {
return;
};
-
sub route_index {
my ($site_name, $site) = _get_site();
return "Could not find site called '$site_name' in the database" if not $site;
my $path = request->path_info;
my $data = Dwimmer::Admin::get_page_data($site, $path);
+
if ($data) {
- $data->{body} =~ s{\[([\w .\$@%]+)\]}{<a href="$1">$1</a>}g;
+ if ($data->{body} =~ s{\[poll://([^]]+)\]}{}) {
+ my $poll = $1;
+ if (not params->{submitted}) {
+ $data->{body} = _poll($poll);
+ }
+ }
+
+ $data->{body} =~ s{\[(\w+)://([^]]+)\]}{_process($1, $2)}eg;
+
+ $data->{body} =~ s{\[([\w .\$@%-]+)\]}{<a href="$1">$1</a>}g;
return Dwimmer::Admin::render_response('index', { page => $data });
} else {
- return Dwimmer::Admin::render_response('error', { page_does_not_exist => 1 });
+ # TODO: actually this should check if the user has the right to create a new page
+ # on this site
+ if (session->{logged_in}) {
+ return Dwimmer::Admin::render_response('error', { page_does_not_exist => 1, creation_offer => 1 });
+ } else {
+ return Dwimmer::Admin::render_response('error', { page_does_not_exist => 1 });
+ }
}
};
-get qr{^/([a-zA-Z0-9][\w .\$@%]*)?$} => \&route_index;
+get qr{^/([a-zA-Z0-9][\w .\$@%-]*)?$} => \&route_index;
+
+# TODO plan:
+# when a pages is marked as a "poll" there are going to be two parts of it
+# one is a json file describing the actual poll
+# the other is the content of the page in the database that will be shown upon posting the poll
+# actually this probbaly should be shown only if we get a parmater in the get request.
+# and the whole thing will be replaced by the result page once the poll is closed.
+post '/poll' => sub {
+ my $id = params->{id};
+ return Dwimmer::Admin::render_response('error', { invalid_poll_id => $id })
+ if $id !~ /^[\w-]+$/;
+
+ my $json_file = path(config->{appdir}, 'polls', "$id.json");
+ return Dwimmer::Admin::render_response('error', { poll_not_found => $id })
+ if not -e $json_file;
+
+ my $log_file = path(config->{appdir}, 'polls', "$id.txt");
+ my %data = params();
+ $data{IP} = request->address;
+ $data{TS} = time;
+ $data{SID} = session->id;
+ if (open my $fh, '>>', $log_file) {
+ flock($fh, LOCK_EX);
+ print $fh to_json(\%data), "\n";
+ close $fh;
+ }
+ redirect request->uri_base . "/$id?submitted=1";
+};
+
+sub _poll {
+ my ($action) = @_;
+ if ($action !~ m{^[\w-]+$}) {
+ return qq{Invalid poll name "$action"};
+ }
+ my $json_file = path(config->{appdir}, 'polls', "$action.json");
+ if (not -e $json_file) {
+ debug("File '$json_file' not found");
+ return "Poll Not found";
+ }
+ my $data = eval { from_json scalar read_file $json_file };
+ if ($@) {
+ debug("Could not read json file '$json_file': $@");
+ return "Could not read poll data";
+ }
+
+ my $html;
+ open my $out, '>', \$html or die;
+ my $t = Template->new(
+ ABSOLUTE => 1,
+# encoding: 'utf8'
+ START_TAG => '<%',
+ END_TAG =>'%>',
+ );
+ #return path(config->{appdir}, 'views', 'poll.tt') . -s path(config->{appdir}, 'views', 'poll.tt');
+ $t->process(path(config->{appdir}, 'views', 'poll.tt'), {poll => $data}, $out);
+ #use Capture::Tiny qw();
+ #my ($out, $err) = Capture::Tiny::capture { $t->process(path(config->{appdir}, 'views', 'poll.tt'), {poll => $data}) };
+ close $out;
+ return $html;
+}
+
+sub _process {
+ my ($scheme, $action) = @_;
+ if ($scheme eq 'http' or $scheme eq 'https') {
+ return qq{<a href="$scheme://$action">$action</a>};
+ }
+
+
+ return qq{Unknown scheme: "$scheme"};
+}
true;
@@ -65,3 +169,4 @@ modify it under the same terms as Perl 5 itself.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
+
Oops, something went wrong.

0 comments on commit e79ae82

Please sign in to comment.