<commit_before># With http://github.com/rails/rails/commit/104898fcb7958bcb69ba0239d6de8aa37f2da9ba
# Rails edge (2.3) reverted all the nice oop changes that were introduced to
# asset_tag_helper in 2.2 ... so no point to code against the 2.2'ish API
# any more. Ok, let's instead overwrite everything. OMG ... suck, why does
# this so remind me of PHP.

require 'action_view/helpers/asset_tag_helper'

module ActionView
  module Helpers
    module AssetTagHelper
      def theme_javascript_path(theme, source)
        theme_compute_public_path(theme, source, theme.url + '/javascripts', 'js')
      end
      alias_method :theme_path_to_javascript, :theme_javascript_path

      def theme_javascript_include_tag(theme_id, *sources)
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options = sources.extract_options!.stringify_keys
        cache   = options.delete("cache")
        recursive = options.delete("recursive")

        if ActionController::Base.perform_caching && cache
          joined_javascript_name = (cache == true ? "all" : cache) + ".js"
          joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name)

          paths = theme_compute_javascript_paths(theme, sources, recursive)
          theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path)
          theme_javascript_src_tag(theme, joined_javascript_name, options)
        else
          theme_expand_javascript_sources(theme, sources, recursive).collect do |source|
            theme_javascript_src_tag(theme, source, options)
          end.join("\n")
        end
      end

      def theme_stylesheet_path(theme, source)
        theme_compute_public_path(theme, source, theme.url + '/stylesheets', 'css')
      end
      alias_method :theme_path_to_stylesheet, :theme_stylesheet_path

      def theme_stylesheet_link_tag(theme_id, *sources)
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options = sources.extract_options!.stringify_keys
        cache   = options.delete("cache")
        recursive = options.delete("recursive")

        if ActionController::Base.perform_caching && cache
          joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
          joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name)

          paths = theme_compute_stylesheet_paths(theme, sources, recursive)
          theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path)
          theme_stylesheet_tag(theme, joined_stylesheet_name, options)
        else
          theme_expand_stylesheet_sources(theme, sources, recursive).collect do |source|
            theme_stylesheet_tag(theme, source, options)
          end.join("\n")
        end
      end

      def theme_image_path(theme, source)
        theme_compute_public_path(theme, source, theme.url + '/images')
      end
      alias_method :theme_path_to_image, :theme_image_path # aliased to avoid conflicts with an image_path named route

      def theme_image_tag(theme_id, source, options = {})
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options.symbolize_keys!
        options[:src] = theme_path_to_image(theme, source)
        options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize

        if size = options.delete(:size)
          options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
        end

        if mouseover = options.delete(:mouseover)<commit_msg>Allow *_path methods in AssetTagHelper to accept a theme id instead of an actual theme object.<commit_after># With http://github.com/rails/rails/commit/104898fcb7958bcb69ba0239d6de8aa37f2da9ba
# Rails edge (2.3) reverted all the nice oop changes that were introduced to
# asset_tag_helper in 2.2 ... so no point to code against the 2.2'ish API
# any more. Ok, let's instead overwrite everything. OMG ... suck, why does
# this so remind me of PHP.

require 'action_view/helpers/asset_tag_helper'

module ActionView
  module Helpers
    module AssetTagHelper
      def theme_javascript_path(theme, source)
        theme = @controller.site.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
        theme_compute_public_path(theme, source, theme.url + '/javascripts', 'js')
      end
      alias_method :theme_path_to_javascript, :theme_javascript_path

      def theme_javascript_include_tag(theme_id, *sources)
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options = sources.extract_options!.stringify_keys
        cache   = options.delete("cache")
        recursive = options.delete("recursive")

        if ActionController::Base.perform_caching && cache
          joined_javascript_name = (cache == true ? "all" : cache) + ".js"
          joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name)

          paths = theme_compute_javascript_paths(theme, sources, recursive)
          theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path)
          theme_javascript_src_tag(theme, joined_javascript_name, options)
        else
          theme_expand_javascript_sources(theme, sources, recursive).collect do |source|
            theme_javascript_src_tag(theme, source, options)
          end.join("\n")
        end
      end

      def theme_stylesheet_path(theme, source)
        theme = @controller.site.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
        theme_compute_public_path(theme, source, theme.url + '/stylesheets', 'css')
      end
      alias_method :theme_path_to_stylesheet, :theme_stylesheet_path

      def theme_stylesheet_link_tag(theme_id, *sources)
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options = sources.extract_options!.stringify_keys
        cache   = options.delete("cache")
        recursive = options.delete("recursive")

        if ActionController::Base.perform_caching && cache
          joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
          joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name)

          paths = theme_compute_stylesheet_paths(theme, sources, recursive)
          theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path)
          theme_stylesheet_tag(theme, joined_stylesheet_name, options)
        else
          theme_expand_stylesheet_sources(theme, sources, recursive).collect do |source|
            theme_stylesheet_tag(theme, source, options)
          end.join("\n")
        end
      end

      def theme_image_path(theme, source)
        theme = @controller.site.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
        theme_compute_public_path(theme, source, theme.url + '/images')
      end
      alias_method :theme_path_to_image, :theme_image_path # aliased to avoid conflicts with an image_path named route

      def theme_image_tag(theme_id, source, options = {})
        theme = @controller.site.themes.find_by_theme_id(theme_id)
        return("could not find theme with the id #{theme_id}") unless theme

        options.symbolize_keys!
        options[:src] = theme_path_to_image(theme, source)
        options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize

        if size = options.delete(:size)
          options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
        end

        if mouseover = options.delete(:mouseover)
{'fraction_non_alphanumeric': 0.09675816668736803, 'fraction_numerical': 0.0069556576822754936, 'mean_word_length': 3.4634146341463414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2649590', 'n_tokens_mistral': 2375, 'n_tokens_neox': 2306, 'n_words': 524}