summaryrefslogtreecommitdiff
path: root/app/controllers/controller_extension
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-07-14 13:04:30 +0200
committerAzul <azul@leap.se>2014-07-14 13:04:30 +0200
commitf07c952c870bfb8634ef0d80737b67a1eec760f6 (patch)
treeba6945d4ceb7ef1adfff92c9de89482e345c6838 /app/controllers/controller_extension
parentb80be9832526ee956b3a73a634896c6cd8d2914e (diff)
send config files from ConfigsController
Diffstat (limited to 'app/controllers/controller_extension')
-rw-r--r--app/controllers/controller_extension/json_file.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/controller_extension/json_file.rb b/app/controllers/controller_extension/json_file.rb
new file mode 100644
index 0000000..0cb4b6d
--- /dev/null
+++ b/app/controllers/controller_extension/json_file.rb
@@ -0,0 +1,22 @@
+module ControllerExtension::JsonFile
+ extend ActiveSupport::Concern
+
+ protected
+
+ def send_file
+ if stale?(:last_modified => @file.mtime)
+ response.content_type = 'application/json'
+ render :text => @file.read
+ end
+ end
+
+ def fetch_file
+ if File.exists?(@filename)
+ @file = File.new(@filename)
+ else
+ not_found
+ end
+ end
+
+end
+