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
<% if scrivito_user %> | |
<%# opt out of turbolinks when running inside Scrivito %> | |
<body data-no-turbolink> | |
<% else %> | |
<body> | |
<% end %> |
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
# put this into config/initializers/scrivito_monkey_patch.rb | |
scrivito_version = Gem.loaded_specs["scrivito"].version | |
scrivito_gem_version = Gem::Version.new(scrivito_version) | |
checked_versions = [">= 0.71.0", "< 1.3.0"] | |
blob_render_versions = [">= 1.2.0.rc1"] | |
$_scrivito_does_blob_render = | |
Gem::Requirement.new(blob_render_versions).satisfied_by?(scrivito_gem_version) |
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
<%= scrivito_image_tag widget, :image, { | |
class: 'image-widget', | |
srcset: srcset_for(widget.image) | |
}, transform: {width: 1280} %> |
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
# put this into config/initializers/scrivito_monkey_patch.rb | |
scrivito_version = Gem.loaded_specs["scrivito"].version | |
checked_versions = [">= 0.30.0", "<= 0.50.0"] | |
requirement = Gem::Requirement.new(checked_versions) | |
if !requirement.satisfied_by?(Gem::Version.new(scrivito_version)) | |
raise "this monkey patch was designed for scrivito versions #{checked_versions}. "\ | |
"you upgraded scrivito to #{scrivito_version}, please ensure it still applies and works" |
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
// make the first tab of each bootstrap tab panel active | |
scrivito.on("content", function(content) { | |
// explanation of find & addBack usage see: | |
// http://stackoverflow.com/questions/2828019 | |
$(content). | |
find("[role=tabpanel]").addBack("[role=tabpanel]"). | |
each(function(_, panel) { | |
$(panel).find(".nav-tabs > *:first").addClass("active"); | |
$(panel).find(".tab-content > *:first").addClass("active"); | |
}); |
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
def kittenize(obj) | |
puts "uploading kitten..." | |
kitten = Image.create( | |
_path: "/egal/#{rand}", | |
blob: File.new("/Users/krishane/Desktop/kitten.jpg") | |
) | |
puts "kittenizing..." | |
obj.update( | |
main_content: obj.main_content.map do |widget| |
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
Workspace = RailsConnector::Workspace | |
CmsRestApi = RailsConnector::CmsRestApi | |
# setup content | |
workspace_id = CmsRestApi.post("/workspaces", {})["id"] | |
CmsRestApi.put("/workspaces/#{workspace_id}/objs/#{Obj.root.id}", obj: {title: "Big change!"}) | |
# this is what RailsConnector::CacheMiddleware does | |
RailsConnector::CmsBackend.begin_caching |
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
# include this in your shell profile | |
function rake { | |
if [ -e "Gemfile" ] | |
then | |
bundle exec rake $@ | |
else | |
`which rake` $@ | |
fi | |
} |