]> git.openstreetmap.org Git - rails.git/commitdiff
Switch to using jbuilder for JSON templates
authorTom Hughes <tom@compton.nu>
Thu, 14 Nov 2019 19:29:14 +0000 (19:29 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 20 Nov 2019 18:54:04 +0000 (18:54 +0000)
Gemfile
Gemfile.lock
app/views/api/notes/_note.json.jbuilder [moved from app/views/api/notes/_note.json.jsonify with 81% similarity]
app/views/api/notes/index.json.jbuilder [moved from app/views/api/notes/index.json.jsonify with 70% similarity]
app/views/api/notes/show.json.jbuilder [new file with mode: 0644]
app/views/api/notes/show.json.jsonify [deleted file]
app/views/messages/destroy.json.jbuilder [moved from app/views/messages/destroy.json.jsonify with 100% similarity]
app/views/messages/mark.json.jbuilder [moved from app/views/messages/mark.json.jsonify with 100% similarity]

diff --git a/Gemfile b/Gemfile
index c2bb066b7c9c291bd8854f27dc73844a5cd9cf4a..d157a3eccc82a53184f567634ccd126cf216397e 100644 (file)
--- 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
index dd6ddfc88bae93ccd705bf9c987b768a2ce060d0..147ab83e5d086b875244b4ed93001c1be688b3ed 100644 (file)
@@ -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)
similarity index 81%
rename from app/views/api/notes/_note.json.jsonify
rename to app/views/api/notes/_note.json.jbuilder
index b964399225350d30cf48aa7786e0c4eda41d9fb7..34f79688073249d00b7edf78cff1b05198ab77de 100644 (file)
@@ -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
similarity index 70%
rename from app/views/api/notes/index.json.jsonify
rename to app/views/api/notes/index.json.jbuilder
index bfc8ffcf854f3ed87c9569d05168462c8d52a725..7909391f5ae939f231121b01c958134ad0afce72 100644 (file)
@@ -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 (file)
index 0000000..71d9408
--- /dev/null
@@ -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 (file)
index 10d1272..0000000
+++ /dev/null
@@ -1 +0,0 @@
-json.ingest! render(@note)