From b5d4c262ddf559e8f0053d40514c8d33a1e959ab Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 14 Nov 2019 19:29:14 +0000 Subject: [PATCH] Switch to using jbuilder for JSON templates --- Gemfile | 3 +-- Gemfile.lock | 9 +++------ .../notes/{_note.json.jsonify => _note.json.jbuilder} | 8 ++++---- .../notes/{index.json.jsonify => index.json.jbuilder} | 2 +- app/views/api/notes/show.json.jbuilder | 1 + app/views/api/notes/show.json.jsonify | 1 - .../{destroy.json.jsonify => destroy.json.jbuilder} | 0 .../messages/{mark.json.jsonify => mark.json.jbuilder} | 0 8 files changed, 10 insertions(+), 14 deletions(-) rename app/views/api/notes/{_note.json.jsonify => _note.json.jbuilder} (81%) rename app/views/api/notes/{index.json.jsonify => index.json.jbuilder} (70%) create mode 100644 app/views/api/notes/show.json.jbuilder delete mode 100644 app/views/api/notes/show.json.jsonify rename app/views/messages/{destroy.json.jsonify => destroy.json.jbuilder} (100%) rename app/views/messages/{mark.json.jsonify => mark.json.jbuilder} (100%) diff --git a/Gemfile b/Gemfile index c2bb066b7..d157a3ecc 100644 --- a/Gemfile +++ b/Gemfile @@ -28,8 +28,7 @@ gem "coffee-rails", "~> 4.2" gem "jquery-rails" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -# gem 'jbuilder', '~> 2.0' -gem "jsonify-rails" +gem "jbuilder", "~> 2.7" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", ">= 1.1.0", :require => false diff --git a/Gemfile.lock b/Gemfile.lock index dd6ddfc88..147ab83e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,17 +221,14 @@ GEM image_size (2.0.2) in_threads (1.5.3) jaro_winkler (1.5.4) + jbuilder (2.9.1) + activesupport (>= 4.2.0) jmespath (1.4.0) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.2.0) - jsonify (0.3.1) - multi_json (~> 1.0) - jsonify-rails (0.3.2) - actionpack - jsonify (< 0.4.0) jwt (2.2.1) kgio (2.11.2) kramdown (2.1.0) @@ -478,9 +475,9 @@ DEPENDENCIES http_accept_language (~> 2.0.0) i18n-js (>= 3.0.0) image_optim_rails + jbuilder (~> 2.7) jquery-rails json - jsonify-rails kgio kramdown libxml-ruby (>= 2.0.5) diff --git a/app/views/api/notes/_note.json.jsonify b/app/views/api/notes/_note.json.jbuilder similarity index 81% rename from app/views/api/notes/_note.json.jsonify rename to app/views/api/notes/_note.json.jbuilder index b96439922..34f796880 100644 --- a/app/views/api/notes/_note.json.jsonify +++ b/app/views/api/notes/_note.json.jbuilder @@ -2,7 +2,7 @@ json.type "Feature" json.geometry do json.type "Point" - json.coordinates [ note.lon.to_f, note.lat.to_f ] + json.coordinates [note.lon.to_f, note.lat.to_f] end json.properties do @@ -16,12 +16,12 @@ json.properties do json.close_url close_note_url(note, :format => params[:format]) end - json.date_created note.created_at + json.date_created note.created_at.to_s json.status note.status - json.closed_at note.closed_at if note.closed? + json.closed_at note.closed_at.to_s if note.closed? json.comments(note.comments) do |comment| - json.date comment.created_at + json.date comment.created_at.to_s if comment.author json.uid comment.author.id diff --git a/app/views/api/notes/index.json.jsonify b/app/views/api/notes/index.json.jbuilder similarity index 70% rename from app/views/api/notes/index.json.jsonify rename to app/views/api/notes/index.json.jbuilder index bfc8ffcf8..7909391f5 100644 --- a/app/views/api/notes/index.json.jsonify +++ b/app/views/api/notes/index.json.jbuilder @@ -1,5 +1,5 @@ json.type "FeatureCollection" json.features(@notes) do |note| - json.ingest! render(note) + json.partial! note end diff --git a/app/views/api/notes/show.json.jbuilder b/app/views/api/notes/show.json.jbuilder new file mode 100644 index 000000000..71d9408c2 --- /dev/null +++ b/app/views/api/notes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! @note diff --git a/app/views/api/notes/show.json.jsonify b/app/views/api/notes/show.json.jsonify deleted file mode 100644 index 10d127291..000000000 --- a/app/views/api/notes/show.json.jsonify +++ /dev/null @@ -1 +0,0 @@ -json.ingest! render(@note) diff --git a/app/views/messages/destroy.json.jsonify b/app/views/messages/destroy.json.jbuilder similarity index 100% rename from app/views/messages/destroy.json.jsonify rename to app/views/messages/destroy.json.jbuilder diff --git a/app/views/messages/mark.json.jsonify b/app/views/messages/mark.json.jbuilder similarity index 100% rename from app/views/messages/mark.json.jsonify rename to app/views/messages/mark.json.jbuilder -- 2.43.2