<commit_before>module Lokka
  module Before
    def self.registered(app)
      app.before do
        @site = Site.first
        @title = @site.title
        @theme = Theme.new(settings.theme, request.user_agent =~ /iPhone|iPad|Android/)
        @theme_types = []
        if @theme.exist_i18n?
          R18n.extension_places.reject! do |i18n|
            i18n.dir.match(@theme.root_dir)
          end
          R18n.extension_places << R18n::Loader::YAML.new(@theme.i18n_dir) if @theme.exist_i18n?
        end
        if params[:locale]
          session[:locale] = params[:locale]
          redirect request.referrer
        end
      end

      app.before %r{(?!^/admin/login$)^/admin/.*$} do
        login_required
      end
    end
  end
end<commit_msg>enable to switch to pc theme even on mobile<commit_after>module Lokka
  module Before
    def self.registered(app)
      app.before do
        @site = Site.first
        @title = @site.title

        theme = request.cookies['theme']
        if params[:theme]
          theme = params[:theme]
          response.set_cookie('theme', params[:theme])
        end

        @theme = Theme.new(settings.theme, theme != 'pc' && request.user_agent =~ /iPhone|iPad|Android/)
        @theme_types = []
        if @theme.exist_i18n?
          R18n.extension_places.reject! do |i18n|
            i18n.dir.match(@theme.root_dir)
          end
          R18n.extension_places << R18n::Loader::YAML.new(@theme.i18n_dir) if @theme.exist_i18n?
        end
        if params[:locale]
          session[:locale] = params[:locale]
          redirect request.referrer
        end
      end

      app.before %r{(?!^/admin/login$)^/admin/.*$} do
        login_required
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12023121387283237, 'fraction_numerical': 0.018497109826589597, 'mean_word_length': 2.036842105263158, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7277537', 'n_tokens_mistral': 576, 'n_tokens_neox': 543, 'n_words': 108}