Sha256: 9b137c1439443b72a8d22b33c635855d958ef01706c386aa6c09c1e4c67bd94c
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
def self.included host_class host_class.mattr_accessor :file_content_mod_name host_class.file_content_mod_name = Card::Set.mod_name(caller) end # FIXME: these should abstracted and configured on the types # (same codes for `rake card:create:codefile`) # @return [Array<String>, String] the name of file(s) to be loaded def source_files case type_id when Card::CoffeeScriptID then "#{codename}.js.coffee" when Card::JavaScriptID then "#{codename}.js" when Card::CssID then "#{codename}.css" when Card::ScssID then "#{codename}.scss" end end def source_dir case type_id when Card::CoffeeScriptID, Card::JavaScriptID then "lib/javascript" when Card::CssID, Card::ScssID then "lib/stylesheets" else "lib" end end def find_file filename mod_path = Card::Mod.dirs.path file_content_mod_name file_path = File.join(mod_path, source_dir, filename) unless File.exist?(file_path) Rails.logger.info "couldn't locate file #{filename} at #{file_path}" return nil end file_path end def existing_source_paths Array.wrap(source_files).map do |filename| find_file(filename) end.compact end def source_changed? since: existing_source_paths.any? { |path| ::File.mtime(path) > since } end def content Array.wrap(source_files).map do |filename| if (source_path = find_file filename) Rails.logger.info "reading file: #{source_path}" File.read source_path end end.compact.join "\n" end format :html do view :input do "Content is stored in file and can't be edited." end view :file_size do "#{card.name}: #{number_to_human_size card.content.bytesize}" end def short_content fa_icon("exclamation-circle", class: "text-muted pr-2") + wrap_with(:span, "file", class: "text-muted") end def standard_submit_button multi_card_editor? ? super : "" end end def coffee_files files files.map { |f| "script_#{f}.js.coffee" } end def scss_files files files.map { |f| "style_#{f}.scss" } end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
card-1.99.3 | mod/core/set/abstract/code_file.rb |
card-1.99.2 | mod/core/set/abstract/code_file.rb |