Permalink
Browse files

support japanese holiday.

  • Loading branch information...
s-aska committed Dec 12, 2012
1 parent 5eff50c commit 86f64d7ee94a7119461dbc2758a5c7dae8cf2893
View
@@ -5,29 +5,35 @@ WriteMakefile(
AUTHOR => 'Shinichiro Aska <s.aska.org@gmail.com>',
VERSION_FROM => 'lib/DoubleSpark.pm',
PREREQ_PM => {
'Amon2' => '2.37',
'Text::Xslate' => '1.1005',
'Text::Xslate::Bridge::TT2Like' => '0.00008',
'Plack::Middleware::ReverseProxy' => '0.09',
'HTML::FillInForm::Lite' => '1.09',
'Time::Piece' => '1.20',
'SQL::Maker' => '1.03',
'Crypt::SaltedHash' => '0.06',
'Amon2' => '2.37',
'Crypt::SaltedHash' => '0.05',
'Calendar::Japanese::Holiday' => '',
'Data::ICal' => '0.16',
'DBD::mysql' => '4.021',
'Email::Sender' => '0.110001',
'Email::Valid::Loose' => '0.05',
'Facebook::Graph' => '1.0300',
'FormValidator::Lite' => '0.25',
'Furl' => '0.38',
'HTML::FillInForm::Lite' => '1.09',
'HTTP::Session::State::Cookie' => '0.46',
'JSON::XS' => '2.33',
'Log::Minimal' => '0.08',
'Module::Find' => '0.11',
'Net::OpenID::Consumer::Lite' => '0.03',
'Net::Twitter::Lite' => '0.10004',
'Path::Class' => '0.24',
'Plack::Middleware::Log::Minimal' => '0.06',
'Plack::Middleware::ReverseProxy' => '0.09',
'Plack::Middleware::Scope::Container' => '0.01',
'Scope::Container' => '0.04',
'SQL::Maker' => '1.03',
'String::Random' => '0.22',
'Sub::Retry' => '0.03',
'Teng' => '0.14',
'Text::Xslate' => '1.6001',
'Text::Xslate::Bridge::TT2Like' => '0.00008',
'Time::Piece' => '1.20',
'XML::RSS' => '1.49',
},
MIN_PERL_VERSION => '5.008001',
@@ -1,7 +1,7 @@
server {
listen 80;
server_name tasks.7kai.org;
rewrite ^ https://tasks.7kai.org/ permanent;
listen 80;
server_name tasks.7kai.org task.7kai.org;
rewrite ^ https://tasks.7kai.org/ permanent;
}
server {
listen 443;
View
@@ -3,5 +3,5 @@
my $config = DoubleSpark::Config->new({
base_url => 'http://stage.tasks.7kai.org'
});
$config->{DB}->[0] = 'dbi:mysql:dbname=doublespark_stage;sql-mode=STRICT_TRANS_TABLES';
$config->{DB}->[0] = 'dbi:mysql:dbname=doublespark_stage';
$config;
@@ -433,6 +433,7 @@ app.util.buildMe = function(option, data){
app.data.sub_accounts = data.sub_accounts;
app.data.users = data.users;
app.data.if_modified_lists = data.list_ids;
app.data.holidays = data.holidays;
app.fireEvent('receiveSign', app.data.sign);
@@ -1407,7 +1408,7 @@ app.setup.tasksheet = function(ul){
li.find('> ul.tasks').hide();
li.addClass('task-collapse');
}
} else {
folder.data('closed', false);
folder.removeClass('icon-folder-close').addClass('icon-folder-open');
@@ -26,6 +26,7 @@ $.extend(app, {
task_map: {},
taskli_map: {},
sub_accounts: [],
holidays: {},
messages: null,
animation: true
},
@@ -24,7 +24,7 @@ var app = ns.app = {
WEEK_NAMES_JA: [
'', '', '', '', '', '', ''
],
// Environment
env: {
token: '',
@@ -113,8 +113,8 @@ app.func.debounce = function(f, threshold){
timeout = setTimeout(function(){
f.apply(self, args);
timeout = null;
}, threshold || 100);
timeout = null;
}, threshold || 100);
};
}
app.date.parse = function(str){
@@ -170,6 +170,15 @@ app.date.ymd = function(date){
app.date.mdy = function(date){
return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
}
app.date.is_holiday = function(date){
if (app.env.lang === 'ja') {
var ymd = app.date.ymd(date);
if (ymd in app.data.holidays) {
return app.data.holidays[ymd];
}
}
return false;
}
app.dom.text = function(ele, key){
if (key) {
return ele.data('text-' + key + '-' + app.env.lang);
@@ -59,14 +59,23 @@ app.setup.ganttchartSheet = function(ele){
} else if (date.getDay() === 0 || date.getDay() === 6) {
day.addClass('holiday');
}
var holiday = app.date.is_holiday(date);
if (holiday) {
day.addClass('holiday');
var h2 = day.find('h2');
h2.data('text-ja', app.date.is_holiday(date));
app.setup.tooltip(h2);
}
date.setTime(date.getTime() + (24 * 60 * 60 * 1000));
day_array.push(day);
}
ele.append($(blank));
});
app.fireEvent('initGanttchart',
new Date(now.getFullYear(), now.getMonth(), now.getDate()));
app.addListener('receiveSign', function(){
app.fireEvent('initGanttchart',
new Date(now.getFullYear(), now.getMonth(), now.getDate()));
});
app.addListener('selectDay', function(e){
for (var i = 0, max_i = day_array.length; i < max_i; i++) {
@@ -114,7 +123,7 @@ app.setup.ganttchartListsV3 = function(ul){
li.find('> ul.tasks').hide();
li.addClass('task-collapse');
}
} else {
folder.data('closed', false);
folder.removeClass('icon-folder-close').addClass('icon-folder-open');
@@ -4,11 +4,11 @@ use warnings;
sub new {
my ($class, $args) = @_;
+{
ext_url => 'https://chrome.google.com/webstore/detail/dolhpjcchfcnkcanamhgcgbnmcogdank',
DB => [
'dbi:mysql:dbname=doublespark;sql-mode=STRICT_TRANS_TABLES',
'dbi:mysql:dbname=doublespark',
'root',
'',
+{
@@ -1,6 +1,7 @@
package DoubleSpark::Web::C::API::Account;
use strict;
use warnings;
use Calendar::Japanese::Holiday;
use Digest::MD5 qw(md5_hex);
use DoubleSpark::API::Account;
use DoubleSpark::API::Comment;
@@ -137,6 +138,21 @@ sub me {
}
}
my $holidays = {};
my $time = time - (60 * 60 * 24 * 180);
for my $i (1..12) {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($time);
$year += 1900;
$mon++;
my $days = getHolidays($year, $mon, 1);
for my $day (keys %$days) {
my $date = sprintf('%04d-%02d-%02d', $year, $mon, $day);
$holidays->{ $date } = $days->{ $day };
}
$time += (60 * 60 * 24 * Calendar::Japanese::Holiday::days_in_month($year, $mon));
}
$c->render_json({
success => 1,
sign => $c->sign,
@@ -148,7 +164,8 @@ sub me {
sub_accounts => \@sub_accounts,
lists => \@lists,
list_ids => $list_ids,
users => $users
users => $users,
holidays => $holidays,
});
}

0 comments on commit 86f64d7

Please sign in to comment.