Committer: ssafronova
LJSUP-7103: New update.bml - LJSUP-7108: create assembling widgetU trunk/cgi-bin/LJ/Widget/Template.pm A trunk/cgi-bin/LJ/Widget/UpdateJournal.pm A trunk/htdocs/update2.bml A trunk/htdocs/update2.bml.text A trunk/templates/UpdateJournal/ A trunk/templates/UpdateJournal/main.tmpl
Modified: trunk/cgi-bin/LJ/Widget/Template.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/Template.pm 2010-10-13 05:49:56 UTC (rev 17552) +++ trunk/cgi-bin/LJ/Widget/Template.pm 2010-10-13 09:10:41 UTC (rev 17553) @@ -1,5 +1,5 @@ package LJ::Widget::Template; -# base class for widget of any time (post / ajax / simple(render) ), using template engine +# base class for widget of any type (post / ajax / simple(render) ), using template engine use strict; use base qw(LJ::Widget); @@ -37,11 +37,13 @@ strict => 0, ) or die "Can't open template '$filename': $!"; + # template object already contains 'lj_siteroot' and several same parameters, look LJ/HTML/Template.pm + # also it contains 'ml', 'ljuser', ... functions + $template->param( is_remote_sup => LJ::SUP->is_remote_sup ? 1 : 0, errors => $class->error_list, form_auth => LJ::form_auth(), - siteroot => $LJ::SITEROOT, ); $class->prepare_template_params($template, \%opts); Added: trunk/cgi-bin/LJ/Widget/UpdateJournal.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/UpdateJournal.pm (rev 0) +++ trunk/cgi-bin/LJ/Widget/UpdateJournal.pm 2010-10-13 09:10:41 UTC (rev 17553) @@ -0,0 +1,44 @@ +package LJ::Widget::UpdateJournal; + +use strict; +use base qw(LJ::Widget::Template); +use Carp qw(croak); + +#sub need_res { qw( stc/widgets/examplepostwidget.css ) } + +sub template_filename { + return "$ENV{'LJHOME'}/templates/UpdateJournal/main.tmpl"; +} + +sub prepare_template_params { + my $class = shift; + my $template_obj = shift; + my $opts = shift; + + $template_obj->param(step => 1); + + return; +} + +sub handle_post { + my $class = shift; + my $post = shift; + my %opts = @_; + + if ($post->{text}) { + warn "You entered: $post->{text}\n"; + } + + return; +} + +sub js { + q [ + initWidget: function () { + var self = this; + + }, + ]; +} + +1; Added: trunk/htdocs/update2.bml =================================================================== --- trunk/htdocs/update2.bml (rev 0) +++ trunk/htdocs/update2.bml 2010-10-13 09:10:41 UTC (rev 17553) @@ -0,0 +1,25 @@ +<?page +title=><?_ml .title _ml?> +body<= +<?_code +{ + use strict; + use vars qw($headextra); + + return 'This feature is disabled' unless LJ::is_enabled('update2'); + + # LJ::Widget->handle_post checks LJ::did_post inside + my %from_post = LJ::Widget->handle_post(\%POST, 'UpdateJournal', { get => \%GET }); + + my $ret; + + my $widget = LJ::Widget::UpdateJournal->new; + $headextra .= $widget->wrapped_js; + return $widget->render({ get => \%GET, from_post => \%from_post }); +} +_code?> +<=body +head<= +<?_code return $headextra; _code?> +<=head +page?> Added: trunk/htdocs/update2.bml.text =================================================================== --- trunk/htdocs/update2.bml.text (rev 0) +++ trunk/htdocs/update2.bml.text 2010-10-13 09:10:41 UTC (rev 17553) @@ -0,0 +1,4 @@ +;; -*- coding: utf-8 -*- + +.title=Post to Journal + Property changes on: trunk/htdocs/update2.bml.text ___________________________________________________________________ Added: svn:executable + * Added: trunk/templates/UpdateJournal/main.tmpl =================================================================== --- trunk/templates/UpdateJournal/main.tmpl (rev 0) +++ trunk/templates/UpdateJournal/main.tmpl 2010-10-13 09:10:41 UTC (rev 17553) @@ -0,0 +1 @@ +Hello, world! \ No newline at end of file