Thursday, October 02, 2008

Foorum 0.2.7 release

Please download from http://foorum.googlecode.com/files/Foorum-0.2.7.tar.gz

it's a good code source to learn Catalyst+DBIx::Class+Template and others.

try http://www.foorumbbs.com/

Patches or suggestion is really appreciated.

Thanks.

Labels: ,

Monday, September 15, 2008

Foorum 0.2.2 release

0.2.2 Mon Sep 15 12:03:00
- use Catalyst::Plugin::PageCache '0.19' and key_maker
- split Model/Validation.pm into ResultSet and remove it
- use 'MooseX::TheSchwartz' and 'TheSchwartz::Simple' to replace 'TheSchwartz'

Please download it from http://foorum.googlecode.com/files/Foorum-0.2.2.tar.gz

Thanks.

Labels:

Tuesday, June 17, 2008

3 day 3 release

CPAN generally means responsibility. I released 3 Foorum distribution in the last 3 days.

CPAN means better document. so I tried to use DBICx::AutoDoc to create docs for Foorum::Schema. it's a bit different from the original method in DBICx::AutoDoc. I changed a bit to write pod into Schema files directly.

code are:(briefly)
my $ad = DBICx::AutoDoc->new(
schema => 'Foorum::Schema',
output => File::Spec->catdir($Bin, '..', '..', 'docs'),
);

# rewrite the Schema pm POD
use Template;

my $tt2 = Template->new( { INCLUDE_PATH => $ad->include_path, POST_CHOMP => 0, PRE_CHOMP => 0 } );
my $vars = $ad->get_vars;

# first get the lists of all Foorum::Schema pm files
my @sources = @{ $vars->{sources} };
foreach my $source (@sources) {
my $class = $source->{class}; # Foorum::Schema::User

# make file dir
my @parts_of_modules = split('::', $class);
$parts_of_modules[-1] .= '.pm';
my $file_dir = File::Spec->catfile( $Bin, '..', '..', 'lib', @parts_of_modules );

my $output;
$tt2->process('pod.html', { source => $source }, \$output)
|| die $tt2->error(), "\n";

# replace POD in real module
open(my $fh, '<', $file_dir);
local $/ = undef;
my $in = <$fh>;
close($fh);

my ($code, $pod) = split(/\n1;\n/, $in);
open(my $fh2, '>', $file_dir);
print $fh2 "$code\n1;\n__END__\n\n$output\n";
close($fh2);

print "working on $class\n";
}
Full code can be found in http://foorum.googlecode.com/svn/trunk/bin/misc/dbicx_autodoc.pl

Thanks.

Labels:

Sunday, June 15, 2008

Foorum 0.1.5 release

Finally I release the Foorum 0.1.5 after 2 months later.

CHANGES:
1, Foorum::Search with backend Foorum::Search::Database and Foorum::Search::Sphinx
2, change DATETIME to INT(11) for tables.

it's a release for my little boy diudiu. :)

u can get it from http://foorum.googlecode.com/files/Foorum-0.1.5.tar.gz

and I uploaded to CPAN too.

Thanks.

Labels:

Friday, May 23, 2008

use INT(11) instead of DATETIME for time

well, don't use DATETIME or DATE in database for time, use INT(11) UNSIGNED instead.

the benefits are:
1, u don't need care about MySQL or SQLite or others. NOW() is used by MySQL while CURRENT_TIMESTAMP is used by SQLite. that's important while u developer in MySQL and write test cases by SQLite.
2, compare. while in TT, if u want to compare topic.time with date.now, u need wrap date.now by String.Compare or convert topic.time to int. that's not so easy. and date.format can convert INT to any format u want.

I spent some hours to do the upgrade for Foorum.
and the upgrade pl is simple: create a temp column then update as UNIX_TIMESTAMP, then drop old column and rename temp column.

code is here: http://foorum.googlecode.com/svn/trunk/bin/upgrade/0.1.5/up.pl

Enjoy.

Labels:

Saturday, January 12, 2008

a new blog site for Foorum

I just create a new Bloger site: http://blog.foorumbbs.com/

please subscribe the http://blog.foorumbbs.com/atom.xml

Thanks.

Labels:

Sunday, December 30, 2007

Release Early: Foorum 0.1.1 Release

please download from http://foorum.googlecode.com/files/Foorum-0.1.1.tar.gz

and have fun!

0.1.1 Sun Dec 30 16:19:11 2007
- use Perl::Critic to fix some errors, bin/misc/perlcritic.pl
- use JavaScript::Minifier to minify js files, bin/misc/js-min.pl
- bug fix for message permission check (r160)
- add requires 'Cache::FileCache'; in Makefile.PL (reported by hotsnow)
- use Config::YAML instead of ConfigLoader because Config::YAML is simpler and faster
- new table 'user_settings' & /settings for 'SendUpdateNotification for MyStarredItems' (r208)
- new settings 'show_email_public': can hide email from public (r215)
- Topic RSS && RSS title bug fix.
- What's New page
- Site Admin Settings: /admin/settings to change foorum_local.yml

Labels:

Tuesday, December 25, 2007

Perl::Critic support on Foorum

Perl::Critic is a great CPAN module for every Perl developers.

From Foorum v0.1.1 on, we will support Perl::Critic
the pl URL is http://foorum.googlecode.com/svn/trunk/bin/misc/perlcritic.pl
and the result is at http://foorum.googlecode.com/svn/trunk/bin/misc/critic.txt

and here is a tip from Jeffrey Thalhammer:
http://mail.pm.org/pipermail/pbp-pm/2007-December/000056.html

we can disable the eval "string" alerts by
my $has_proc_pid_file = eval "use Proc::PID::File"; ## no critic (ProhibitStringyEval)


have fun!

Labels:

Monday, December 24, 2007

Release Often - Foorum 0.1.0

I release Foorum 0.1.0 as a Christmas gift. :)

http://foorum.googlecode.com/files/Foorum-0.1.0.tar.gz

Live demo please see: http://www.foorumbbs.com/forum

Changes:

0.1.0 Fri Dec 24 20:56:00 2007
- move trunk to http://foorum.googlecode.com/svn/trunk/
- use jQuery to deal with browser time zone
- UBB js localize
- use Catalyst::Plugin::Cache instead of Catalyst::Plugin::Cache::Memcached
- use jQuery validate.js for register etc. (add validate/messages_cn.js)
- rewrite Model/Email.pm to send email after compose a message
- add Plain/Textile Formatter to post/reply/edit
- add Text::GooglewikiFormat
- new language: Chinese Traditional
- add =pod formatter supports
- My Shared Items

Labels: ,

Wednesday, December 19, 2007

new CPAN module released: Text::GooglewikiFormat

I spent couple of hours last night to write a new CPAN module: Text::GooglewikiFormat

I would use it in my Foorum.

And I would use it to build foorum documents from trunk http://foorum.googlecode.com/svn/wiki.

the syntax is here: http://code.google.com/p/support/wiki/WikiSyntax

have fun!

Labels:

Saturday, December 15, 2007

Foorum demo online!

finally I get the Foorum online. I buy a Dreamhost host plan then install it there.

http://www.foorumbbs.com

have fun!

Labels:

Monday, December 10, 2007

Foorum trunk changed

Sunday, December 09, 2007

Foorum 0.08

The last version of this year. I'll push out a 0.1.0 on next month next year.

http://foorum.googlecode.com/files/Foorum-0.08.tar.gz

Changes:
0.08 Sun Dec 9 16:30:30 2007
- I18N encoding fix
- use the lastest Catalyst::Plugin::Authentication (Store::FromSub::Hash)
- use jQuery flot to do daily chart
- bin/setup.pl
- RSS text fix
- lots of changes are missed.

check out your code from
svn checkout http://foorum.googlecode.com/svn/trunk/ Foorum


have fun! welcome to join us to make a new Catalyst based forum app - Foorum.

Labels:

Friday, October 05, 2007

Foorum snapshots

Foorum v0.07

Foorum, a forum system based on Catalyst + DBIx::Class + Template.

I just spent days of my golden week holiday to write codes for Foorum.

new features:
* job queue: TheSchwartz. to resize profile photo and send scheduled email. it would ease mod_perl to load the whole Foorum.
* use jquery.ui Tabs to beauty most of my pages.
* remove RSS.pm and use template to create RSS feed.

u can download the source code from http://fayland.googlecode.com/files/Foorum.v007.tar.gz

If u want to join me to write this forum system, plz send me an email. Thanks.

Labels: ,

Friday, July 20, 2007

Catalyst debug trick

well, we always meet this when we develop a Catalyst application:
* we want -Debug and StackTrace or DBIC::Schema::Profiler when we develop the Catalyst App.
* we don't want -Debug like in the production server because it costs much.

Sometimes u may want a config name like debug_mode to control whether we want or not.
Here comes my solution:
__PACKAGE__->setup();

__PACKAGE__->log->levels('error', 'fatal'); # for real server
if( __PACKAGE__->config->{debug_mode} ) {

__PACKAGE__->log->enable('debug', 'info', 'warn'); # for developer server
{
# these code are copied from Catalyst.pm setup_log
no strict 'refs';
my $class = __PACKAGE__;
*{"$class\::debug"} = sub { 1 };
}

my @extra_plugins = qw/ StackTrace DBIC::Schema::Profiler /;
__PACKAGE__->setup_plugins( [ @extra_plugins ] );
}
Full code please check Foorum.pm

now u can set debug_mode: 1 in _local.yml when u develop and forget it in production server.

Explanation:
* why we write code after __PACKAGE__->setup(); is because we want __PACKAGE__->config->{debug_mode}. config is setup in ->setup().
* *{"$class\::debug"} = sub { 1 }; means $c->debug is on. code from Catalyst.pm
* __PACKAGE__->setup_plugins( [ @extra_plugins ] ); will setup extra_plugins whenever u want.

@Enjoy;

Labels: ,

Wednesday, June 06, 2007

be careful

my @a = ( 'a', $c->req->param('a'), 'b', $c->req->param('b'), 'c', undef , 'd',, 'f' );$c->res->body(Dumper(\@a));
when we try "?b=1", output:
$VAR1 = [
'a',
'b',
'1',
'c',
undef,
'd',
'f'
];

see? $c->req->param('a') is NOT undef.
so when u try something like
$rs->update( {
column1 => $c->req->param('column1'),
column2 => $c->req->param('column2')
} );
then if column1 param is not specified, this would raise error because $rs try to update column1, column2, $c->req->param('column2'). we want 4 but u give me 3.

so man, be careful of that. :)

Labels: ,

Sunday, May 20, 2007

Foorum v0.03

I just release another version of Foorum at http://code.google.com/p/fayland.

CHANGES:
- remove Plugin::Email. insert into table scheduled_email and use a cron script to send. (19/5/2007)
- remove Plugin::Scheduler. all cron scripts goes to /bin/cron (19/5/2007)
- bug fixes (19/5/2007)

I remove the Email Plugin and create a new table scheduled_email to contain the email content, then use /bin/cron/send_scheduled_email to send emails

and remove the Scheduler. I think crontab is better

and remove such files can reduce the memory usage under mod_perl I think

http://fayland.googlecode.com/files/Foorum-0.03.tar.gz

Enjoy!

Labels:

Tuesday, May 08, 2007

Foorum v0.02

I just release the new version of Foorum v0.02 at http://code.google.com/p/fayland/.

no big changes. u can download it from http://fayland.googlecode.com/files/Foorum-0.02.tar.gz

Thanks.

Labels:

Monday, May 07, 2007

Catalyst PageCache with I18N

well, I have something like as follows in the Foorum Root.pm sub auto:
 # internationalization
$c->stash->{lang} = $c->req->cookie('pref_lang')->value if ($c->req->cookie('pref_lang'));
$c->stash->{lang} ||= $c->user->lang if ($c->user_exists);
$c->stash->{lang} ||= $c->config->{default_pref_lang};
if (my $lang = $c->req->param('set_lang')) {
$lang =~ s/\W+//isg;
if (length($lang) == 2) {
$c->res->cookies->{pref_lang} = { value => $lang };
$c->stash->{lang} = $lang;
}
}
$c->languages( [ $c->stash->{lang} ] );

but the Catalyst::Plugin::PageCache does NOT get along well with the I18N's languages.

so that I patch this module for a bit. to create a new plugin based on that:
package Catalyst::Plugin::PageCacheWithI18N;

use strict;
use warnings;
use Class::C3;
use vars qw/$VERSION/;
$VERSION = '0.01';
use base qw/Catalyst::Plugin::PageCache/;

sub _get_page_cache_key {
my ($c) = @_;

my $key = $c->next::method(@_);
my $lang = $c->req->cookie('pref_lang')->value if ($c->req->cookie('pref_lang'));
$lang ||= $c->user->lang if ($c->user_exists);
$lang ||= $c->config->{default_pref_lang};
if (my $set_lang = $c->req->param('set_lang')) {
$set_lang =~ s/\W+//isg;
if (length($set_lang) == 2) {
$lang = $set_lang;
}
}
$key .= '#' . $lang if ($lang);
return $key;
}

1;


Links: http://fayland.googlecode.com/svn/trunk/Foorum/lib/Catalyst/Plugin/PageCacheWithI18N.pm

Labels: , ,

Tuesday, February 27, 2007

GraphViz::ISA picture for Foorum

I just use GraphViz::ISA to create the ISA relationship of my Catalyst App -- Foorum. that's pretty funny.

http://org22.zorpia.com/0/2819/18044938.44ebe4.png

Labels: ,