/[suikacvs]/markup/html/html5/spec-ja/edit2.cgi
Suika

Diff of /markup/html/html5/spec-ja/edit2.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sun Oct 26 06:50:10 2008 UTC revision 1.7 by wakaba, Fri Oct 31 04:30:24 2008 UTC
# Line 25  if ($path eq '/') { Line 25  if ($path eq '/') {
25                  split /[\x0D\x0A]+/, $cgi->get_parameter ('tags') // ''];                  split /[\x0D\x0A]+/, $cgi->get_parameter ('tags') // ''];
26    
27      my $hash = get_hash ($en);      my $hash = get_hash ($en);
28        my $entry = {en => $en, ja => $ja, tags => $tags,
29                     isPattern => $is_pattern};
30        
31      lock_entry ($hash);      lock_entry ($hash);
32      set_entry ($hash, $is_pattern => {en => $en, ja => $ja, tags => $tags});      set_entry ($hash, $is_pattern => $entry);
33      commit_entries ("$path: $hash updated by $ENV{AUTH_USER}");      commit_entries ("$path: $hash updated by $ENV{REMOTE_USER}");
34        
35        print "Status: 200 Saved\n";
36    
37        my $updates = {$hash => $entry};
38            
39      print "Status: 204 Saved\n\n";      binmode STDOUT, ':encoding(utf-8)';
40        print "Content-Type: application/json\n\n";
41        
42        require JSON;
43        print scalar JSON::objToJson ($updates);
44      exit;      exit;
45    } else {    } else {
46      print q[Status: 405 Method Not Allowed      print q[Status: 405 Method Not Allowed
# Line 42  Allow: POST Line 52  Allow: POST
52    }    }
53  } elsif ($path =~ m#^/([0-9a-f]+)\.json$#) {  } elsif ($path =~ m#^/([0-9a-f]+)\.json$#) {
54    my $hash = $1;    my $hash = $1;
55    my ($is_pattern, $entry) = get_entry ($hash);    my $entry = get_entry_or_fallback_entry ($hash);
   unless (defined $entry->{en}) {  
     $entry = get_fallback_entry ($hash);  
   }  
   $entry->{tags} ||= [] if defined $entry->{en};  
   $entry->{isPattern} = 1 if $is_pattern;  
56    
57    binmode STDOUT, ':encoding(utf-8)';    binmode STDOUT, ':encoding(utf-8)';
58    print "Content-Type: application/json\n\n";    print "Content-Type: application/json\n\n";
# Line 55  Allow: POST Line 60  Allow: POST
60    require JSON;    require JSON;
61    print scalar JSON::objToJson ($entry);    print scalar JSON::objToJson ($entry);
62    exit;    exit;
63    } elsif ($path eq '/updates.json') {
64      my $updates = {};
65      for (get_modified_hashes ()) {
66        $updates->{$_} = get_entry_or_fallback_entry ($_);
67      }
68    
69      binmode STDOUT, ':encoding(utf-8)';
70      print "Content-Type: application/json\n\n";
71    
72      require JSON;
73      print scalar JSON::objToJson ($updates);
74      exit;
75  }  }
76    
77  print q[Content-Type: text/plain ; charset=us-ascii  print q[Content-Type: text/plain ; charset=us-ascii
78  Status: 404 Not Found  Status: 404 Not Found
79    
80  404];  404];
81    
82    ## Author: Wakaba <w@suika.fam.cx>.
83    ## License: Copyright 2008 Wakaba.  You are granted a license to use,
84    ##     reproduce and create derivative works of this script.
85    ## $Date$

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.7

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24