Changeset 27261

Show
Ignore:
Timestamp:
26.04.2013 18:30:12 (6 years ago)
Author:
ak19
Message:

Adding in 2 basic JSON examples for the metadata-server.pl help/usage string that can be pasted in the browser. Still to add help strings for other metadata-server actions that take a JSON parameter.

Location:
main/trunk/greenstone2/perllib/cgiactions
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/baseaction.pm

    r27159 r27261  
    8787        $err_mess .= "\n"; 
    8888        } 
     89 
     90        my @help_examples = (); 
     91        if(defined $action_table->{$a}->{'help-string'}) { 
     92        push(@help_examples, @{$action_table->{$a}->{'help-string'}}); 
     93        } 
     94        if (scalar(@help_examples)>0) { 
     95 
     96        if (scalar(@help_examples)>1) { 
     97            $err_mess .= "    Example(s)  :\n"; 
     98        } else { 
     99            $err_mess .= "    Example  :\n"; 
     100        } 
     101        $err_mess .= join(", \n\n", @help_examples); 
     102        $err_mess .= "\n\nTo be strictly CGI-compliant special chars like double-quotes,&,?,<,> must be URL encoded.\n"; 
     103        } 
     104 
    89105        $err_mess .= "\n"; 
    90106    } 
     
    203219 
    204220 
    205  
    206  
    207221sub authenticate_user 
    208222{ 
     
    449463 
    450464 
    451  
    452  
    453465sub run_script 
    454466{ 
     
    493505} 
    494506 
    495  
    496  
    497  
    4985071; 
  • main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm

    r27222 r27261  
    9090    "set-metadata-array" => {  
    9191        'compulsory-args' => [ "where", "json" ], 
    92         'optional-args'   => [ ] }, 
     92        'optional-args'   => [ ], 
     93        'help-string' => [ 
     94        'A simple example: metadata-server.pl?a=set-metadata-array&where=archives|index|import&c=demo&json=[{"docid":"HASHc5bce2d6d3e5b04e470ec9","metaname":"Title","metavalue":"Tralalala","metamode":"accumulate"},{"docid":"HASHbe483fa4df4e096335d1c8","metaname":"Title","metavalue":"Lala was here","metapos":0, "metamode":"override"}]',  
     95         
     96        'A more complex example: metadata-server.pl?a=set-metadata-array&where=archives|index&c=demo&json=[{"docid":"HASHc5bce2d6d3e5b04e470ec9.1","metatable":[{"metaname":"Title","metavals":["Transformers","Robots in disguise","Autobots"]}],"metamode":"override"},{"docid":"HASHbe483fa4df4e096335d1c8.2","metaname":"Title","metavalue":"Pinky was here","metamode":"accumulate"}]' ] }, 
     97 
     98# The same examples rewritten for when running the metadata-server.pl script from the commandline: 
     99 
     100# the simple example: metadata-server.pl a="set-metadata-array" where="archives|index|import" c="demo" json="[{\"docid\":\"HASHc5bce2d6d3e5b04e470ec9\",\"metaname\":\"Title\",\"metavalue\":\"Tralalala\",\"metamode\":\"accumulate\"},{\"docid\":\"HASHbe483fa4df4e096335d1c8\",\"metaname\":\"Title\",\"metavalue\":\"Lala was here\",\"metapos\":0, \"metamode\":\"override\"}]", 
     101         
     102# the more complex example: metadata-server.pl a="set-metadata-array" where="archives|index" c="demo" json="[{\"docid\":\"HASHc5bce2d6d3e5b04e470ec9.1\",\"metatable\":[{\"metaname\":\"Title\",\"metavals\":[\"Transformers\",\"Robots in disguise\",\"Autobots\"]}],\"metamode\":\"override\"},{\"docid\":\"HASHbe483fa4df4e096335d1c8.2\",\"metaname\":\"Title\",\"metavalue\":\"Pinky was here\",\"metamode\":\"accumulate\"}]" 
    93103                      
    94104    "set-archives-metadata-array" => {