Permalink
Browse files

various fixes of the blog demo.

  • Loading branch information...
1 parent dd1d50c commit 29d06538494524f65d83e2575158da81f4ad800c @agentzh agentzh committed Apr 12, 2010
Showing with 14 additions and 12 deletions.
  1. +2 −2 clients/js/openresty.js
  2. +3 −2 demo/Blog/js/blog.js
  3. +1 −1 demo/Blog/misc/mysql/init-db.sql
  4. +1 −1 demo/Blog/template/sidebar.tt
  5. +7 −6 util/import-model.pl
View
@@ -263,7 +263,7 @@ $ClientP.post = function (url) {
// if (!formId) throw "No form specified.";
if (this.session) args._session = this.session;
- if (!this.session && !args._user)
+ if (!this.session && !args._user && this.user)
args._user = this.user;
args._last_response = this.genId();
@@ -353,7 +353,7 @@ $ClientP.get = function (url, args) {
//if (!this.user) throw "No user specified for OpenResty.";
if (this.session) args._session = this.session;
- if (!this.session && !args._user)
+ if (!this.session && !args._user && this.user)
args._user = this.user;
//args.password = this.password || '';
View
@@ -1,6 +1,6 @@
var account = 'agentzh';
-//var host = 'http://10.32.24.13:1984';
-var host = 'http://localhost:1984';
+//var host = 'http://10.32.24.16:8080';
+var host = 'http://localhost:8080';
//var host = 'http://api.eeeeworks.org';
//var host = 'http://api.openresty.org';
//var host = 'http://10.62.136.86';
@@ -42,6 +42,7 @@ function debug (msg) {
$("#copyright").append(msg + "<br/>");
}
+
$.fn.postprocess = function (className, options) {
return this.find("a[@href*='#']").each( function () {
//debug("HERE!");
@@ -2,7 +2,7 @@
drop table if exists posts;
create table posts (
id serial,
- title varchar(128) not null,
+ title text not null,
content text not null,
author varchar(64) not null,
created timestamp(0) default now() not null,
@@ -73,7 +73,7 @@
<a href="site-binary.tar.gz">Compiled form (.tar.gz)</a>
</li>
<li class="module-list-item">
- <a target="_blank" href="http://github.com/agentzh/openresty/tree/8463c31834e1d007da26b8b6549e4d06b5963b70/demo/[% blog_owner == 'agentzh' ? "Blog" : "Blog2" %]/">
+ <a target="_blank" href="http://github.com/agentzh/ngx_openresty/tree/master/demo/[% blog_owner == 'agentzh' ? "Blog" : "Blog2" %]/">
Source code (Git)
</a>
</li>
View
@@ -6,7 +6,7 @@
use Getopt::Long;
use lib 'lib';
use Params::Util qw( _HASH );
-#use JSON::XS ();
+use JSON::XS ();
use JSON::Syck;
#use WWW::OpenResty::Simple;
use Data::Dumper;
@@ -62,7 +62,7 @@ sub usage {
$user or die "No --user given.\n";
$model or die "No --model given.\n";
-# my $json_xs = JSON::XS->new->utf8->allow_nonref;
+my $json_xs = JSON::XS->new->utf8->allow_nonref;
my $database = 'test';
@@ -83,12 +83,13 @@ sub usage {
my ($sth);
+my @cols;
while (<>) {
#select(undef, undef, undef, 0.1);
#warn "count: ", scalar(@elems), "\n";
next if $. <= $skip;
- # my $row = $json_xs->decode($_);
- my $row = JSON::Syck::Load($_);
+ my $row = $json_xs->decode($_);
+ #my $row = JSON::Syck::Load($_);
if (!defined $row->{id}) {
@@ -100,15 +101,15 @@ sub usage {
}
if (!defined $sth) {
- my @cols = sort keys %$row;
+ @cols = reverse sort keys %$row;
my $cols = join ',', @cols;
my @holders = map { '?' } @cols;
my $holders = join ',', @holders;
$sth = $dbh->prepare("insert into $model ($cols) values ($holders)");
}
my @vals;
- for my $col (sort keys %$row) {
+ for my $col (@cols) {
push @vals, $row->{$col};
}

0 comments on commit 29d0653

Please sign in to comment.