<commit_before>require 'schreihals/version'
require 'sinatra'
require 'haml'
require 'sass'
require 'redcarpet'
require 'schnitzelstyle'
require 'document_mapper'
require 'rack-cache'
require 'coderay'
require 'rack/codehighlighter'

require 'active_support/core_ext/string/inflections'

module Schreihals
  class Post
    include DocumentMapper::Document

    def after_load
      # Set some defaults
      #
      self.attributes = {
        disqus: true,
        status: 'published'
      }.merge(attributes)

      # Set slug
      #
      if !attributes.has_key? :slug
        begin
          match = attributes[:file_name_without_extension].match(/(\d{4}-\d{1,2}-\d{1,2}[-_])?(.*)/)
          attributes[:slug] = match[2]
        rescue NoMethodError => err
        end
      end
    end

    def to_url
      date.present? ? "/#{year}/#{month}/#{day}/#{slug}/" : "/#{slug}/"
    end

    def disqus_identifier
      attributes[:disqus_identifier] || file_name_without_extension
    end

    def disqus?
      disqus && published?
    end

    def published?
      status == 'published'
    end

    def post?
      date.present?
    end

    def page?
      !post?
    end

    # load all posts.
    self.directory = 'posts'
  end

  class App < Sinatra::Application
    set :blog_title, "My Schreihals Blog"
    set :blog_url, ""
    set :author_name, "Author"
    set :disqus_name, nil
    set :google_analytics_id, nil
    set :read_more, "Read Complete Article"

    use Rack::ShowExceptions
    use Rack::Cache
    use Rack::Static, :urls => ["/media"], :root => "public"
    use Rack::Codehighlighter, :coderay, :markdown => true, :element => "pre>code", :pattern => /\A:::(\w+)\s*\n/

    helpers do
      def partial(thing, locals = {})
        name = case thing
          when String then thing
          else thing.class.to_s.demodulize.underscore
        end

        haml :"partials/_#{name}", :locals => { name.to_sym => thing }.merge(locals)
      end<commit_msg>Set some default values I forgot. Duh!<commit_after>require 'schreihals/version'
require 'sinatra'
require 'haml'
require 'sass'
require 'redcarpet'
require 'schnitzelstyle'
require 'document_mapper'
require 'rack-cache'
require 'coderay'
require 'rack/codehighlighter'

require 'active_support/core_ext/string/inflections'

module Schreihals
  class Post
    include DocumentMapper::Document

    def after_load
      # Set some defaults
      #
      self.attributes = {
        disqus: true,
        status: 'published',
        summary: nil,
        link: nil
      }.merge(attributes)

      # Set slug
      #
      if !attributes.has_key? :slug
        begin
          match = attributes[:file_name_without_extension].match(/(\d{4}-\d{1,2}-\d{1,2}[-_])?(.*)/)
          attributes[:slug] = match[2]
        rescue NoMethodError => err
        end
      end
    end

    def to_url
      date.present? ? "/#{year}/#{month}/#{day}/#{slug}/" : "/#{slug}/"
    end

    def disqus_identifier
      attributes[:disqus_identifier] || file_name_without_extension
    end

    def disqus?
      disqus && published?
    end

    def published?
      status == 'published'
    end

    def post?
      date.present?
    end

    def page?
      !post?
    end

    # load all posts.
    self.directory = 'posts'
  end

  class App < Sinatra::Application
    set :blog_title, "My Schreihals Blog"
    set :blog_url, ""
    set :blog_description, ""
    set :author_name, "Author"
    set :disqus_name, nil
    set :google_analytics_id, nil
    set :read_more, "Read Complete Article"

    use Rack::ShowExceptions
    use Rack::Cache
    use Rack::Static, :urls => ["/media"], :root => "public"
    use Rack::Codehighlighter, :coderay, :markdown => true, :element => "pre>code", :pattern => /\A:::(\w+)\s*\n/

    helpers do
      def partial(thing, locals = {})
        name = case thing
          when String then thing
          else thing.class.to_s.demodulize.underscore
        end

        haml :"partials/_#{name}", :locals => { name.to_sym => thing }.merge(locals)
      end
{'fraction_non_alphanumeric': 0.1279527559055118, 'fraction_numerical': 0.002952755905511811, 'mean_word_length': 2.5194805194805197, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6371231', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1339, 'n_words': 321}