-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serve JS and CSS without asset pipeline
- Loading branch information
1 parent
d33737f
commit 84f8970
Showing
10 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_dependency "active_analytics/application_controller" | ||
|
||
module ActiveAnalytics | ||
class AssetsController < ApplicationController | ||
def show | ||
if endpoints.include?(File.basename(request.path)) | ||
expires_in(1.day, public: true) | ||
render(params[:id], mime_type: mime_type) | ||
else | ||
raise ActionController::RoutingError.new | ||
end | ||
end | ||
|
||
private | ||
|
||
def endpoints | ||
return @endpoints if @endpoints | ||
folder = ActiveAnalytics::Engine.root.join("app/views", controller_path) | ||
files = folder.each_child.map { |path| File.basename(path).delete_suffix(".erb") } | ||
@endpoints = files.delete_if { |str| str.start_with?("_") } | ||
end | ||
|
||
def mime_type | ||
Mime::Type.lookup_by_extension(File.extname(request.path).delete_prefix(".")) | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render "charts" %> | ||
<%= render "style" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84f8970
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shroy there is no more asset pipeline dependency. You should give it a try ! (cf #5)
Not released yet
gem "active_analytics", git: "https://github.com/BaseSecrete/active_analytics.git"
.84f8970
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexisbernard Thanks for the heads up! Excited to give it a spin!