<commit_before>require_relative "parsers/dsl"
require_relative 'renderers/update_image_paths'

require_relative 'features/live_ruby'
require_relative 'features/pdf_presentation'
require_relative 'features/preshow'

module ShowOff

  class Server < Sinatra::Application

    def initialize(app=nil)
      super(app)
      require_ruby_files
    end

    def require_ruby_files
      Dir.glob("#{settings.presentation_directory}/*.rb").map { |path| require path }
    end

    set :views, File.dirname(__FILE__) + '/../views'
    set :public_folder, File.dirname(__FILE__) + '/../public'

    set :verbose, false

    set :presentation_directory do
      File.expand_path Dir.pwd
    end

    set :presentation_file, 'showoff'

    set :default_presentation_files, [ 'showoff', 'showoff.json' ]

    def presentation_files
      (Array(settings.presentation_file) + settings.default_presentation_files).compact.uniq
    end

    def load_presentation
      root_node = Parsers::PresentationDirectoryParser.parse settings.presentation_directory,
        :root_path => settings.presentation_directory, :showoff_file => presentation_files

      root_node.add_post_renderer Renderers::UpdateImagePaths.new :root_path => settings.presentation_directory
      root_node
    end

    helpers do

      def css(filepath)
        %{<link rel="stylesheet" href="css/#{filepath}" type="text/css"/>}
      end

      def js(filepath)
        %{<script type="text/javascript" src="js/#{filepath}"></script>}
      end

      def custom_css_files
        Dir.glob("#{settings.presentation_directory}/*.css").map do |path|

          relative_path = path.gsub(settings.presentation_directory,'file')

          %{<link rel="stylesheet" href="#{relative_path}" type="text/css"/>}
        end.join("\n")
      end

      def custom_js_files
        Dir.glob("#{settings.presentation_directory}/*.js").map do |path|

          relative_path = path.gsub(settings.presentation_directory,'file')

          %{<script type="text/javascript" src="#{relative_path}"></script>}
        end.join("\n")
      end

      def presentation
        load_presentation
      end

      def title<commit_msg>FIX: Assets paths starting in presenting directory<commit_after>require_relative "parsers/dsl"
require_relative 'renderers/update_image_paths'

require_relative 'features/live_ruby'
require_relative 'features/pdf_presentation'
require_relative 'features/preshow'

module ShowOff

  class Server < Sinatra::Application

    def initialize(app=nil)
      super(app)
      require_ruby_files
    end

    def require_ruby_files
      Dir.glob("#{settings.presentation_directory}/*.rb").map { |path| require path }
    end

    set :views, File.dirname(__FILE__) + '/../views'
    set :public_folder, File.dirname(__FILE__) + '/../public'

    set :verbose, false

    set :presentation_directory do
      File.expand_path Dir.pwd
    end

    set :presentation_file, 'showoff'

    set :default_presentation_files, [ 'showoff', 'showoff.json' ]

    def presentation_files
      (Array(settings.presentation_file) + settings.default_presentation_files).compact.uniq
    end

    def load_presentation
      root_node = Parsers::PresentationDirectoryParser.parse settings.presentation_directory,
        :root_path => settings.presentation_directory, :showoff_file => presentation_files

      root_node.add_post_renderer Renderers::UpdateImagePaths.new :root_path => settings.presentation_directory
      root_node
    end

    helpers do

      def css(filepath)
        %{<link rel="stylesheet" href="css/#{filepath}" type="text/css"/>}
      end

      def js(filepath)
        %{<script type="text/javascript" src="js/#{filepath}"></script>}
      end

      def custom_css_files
        Dir.glob("#{settings.presentation_directory}/*.css").map do |path|

          relative_path = path.sub(settings.presentation_directory,'file')

          %{<link rel="stylesheet" href="#{relative_path}" type="text/css"/>}
        end.join("\n")
      end

      def custom_js_files
        Dir.glob("#{settings.presentation_directory}/*.js").map do |path|

          relative_path = path.sub(settings.presentation_directory,'file')

          %{<script type="text/javascript" src="#{relative_path}"></script>}
        end.join("\n")
      end

      def presentation
        load_presentation
      end

      def title
{'fraction_non_alphanumeric': 0.11664003652134215, 'fraction_numerical': 0.0, 'mean_word_length': 3.3601990049751245, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '6161821', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1246, 'n_words': 239}