Skip to content

Commit

Permalink
Make JSON output content.
Browse files Browse the repository at this point in the history
This outputs in raw wiki and html.
Also fix the number of tests.
This fixes #14
  • Loading branch information
rjw1 committed Jul 7, 2013
1 parent 9132793 commit 44c2fd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/OpenGuides/JSON.pm
Expand Up @@ -97,6 +97,8 @@ sub emit_json {
$data->{categories} = $node_data{metadata}{category} || [];
$data->{locales} = $node_data{metadata}{locale} || [];
$data->{summary} = $node_data{metadata}{summary}[0] || '';
$data->{content} = $node_data{content};
$data->{formatted_content} = $wiki->format($node_data{content});
$data->{node_image} = $node_data{metadata}{node_image}[0]|| '';
$data->{node_image_url} = $node_data{metadata}{node_image_url}[0]|| '';
$data->{node_image_licence} = $node_data{metadata}{node_image_licence}[0]|| '';
Expand Down
6 changes: 4 additions & 2 deletions t/210_json.t
Expand Up @@ -16,7 +16,7 @@ if ( $@ ) {
plan skip_all => "DBD::SQLite could not be used - no database to test with. ($error)";
}

plan tests => 31;
plan tests => 36;

# clear out the database
OpenGuides::Test::refresh_db();
Expand Down Expand Up @@ -74,7 +74,7 @@ OpenGuides::Test->write_data(
OpenGuides::Test->write_data(
guide => $guide,
node => "Calthorpe Arms",
content => "CAMRA-approved pub near King's Cross",
content => "CAMRA-approved pub near King's Cross [http://example.com example review] [[Calthorpe Arms]]",
comment => "Stub page, please update!",
username => "Kake",
postcode => "WC1X 8JR",
Expand Down Expand Up @@ -135,6 +135,8 @@ like( $json, qr|"postcode":"WC1X 8JR"|, "postcode" );
like( $json, qr|"latitude":"51.524193"|, "latitude" );
like( $json, qr|"longitude":"-0.114436"|, "longitude" );
like( $json, qr|"summary":"a nice pub"|, "summary (description)" );
like( $json, qr|"content":"CAMRA-approved pub near King's Cross|, "content" );
like( $json, qr|"formatted_content":"<p>CAMRA-approved pub near King's Cross <a href=|, "formatted content" );
like( $json, qr|"node_image":"http://example.com/calthorpe.jpg"|, "node image" );
like( $json, qr|"node_image_url":"http://example.com/image/calthorpe.html"|, "node image url" );
like( $json, qr|"node_image_licence":"http://example.com/licence"|, "node image licence" );
Expand Down

0 comments on commit 44c2fd3

Please sign in to comment.