<commit_before>module RoutingHelper

	def route_index_page(params)

		if !params[:search].blank?
			gloalize Post.where("(post_title LIKE :p or post_slug LIKE :p2 or post_content LIKE :p3) and (post_type != 'autosave')", {:p => "%#{params[:search]}%", :p2 => "%#{params[:search]}%", :p3 => "%#{params[:search]}%"})
			add_breadcrumb "Home", :root_path, :title => "Home"
			add_breadcrumb "Search", "/"
			render :template => "theme/#{current_theme}/search"

		else

			home_id = Setting.get('home_page')	
			@content = Post.find(home_id)
			gloalize @content
			render_template 'home'
		end


	end

	def render_template(default)



		if !@content.post_template.blank?

			if File.exists?("app/views/theme/#{current_theme}/template-#{@content.post_template.downcase}.html.erb")

				render :template => "theme/#{current_theme}/template-#{@content.post_template.downcase}"

			else

				if File.exists?("app/views/theme/#{current_theme}/#{default}.html.erb")	

					render :template => "theme/#{current_theme}/#{default}"
				else 

					render :template => "theme/#{current_theme}/page.html.erb"

				end

			end

		else

			if File.exists?("app/views/theme/#{current_theme}/#{default}.html.erb")

				render :template => "theme/#{current_theme}/#{default}"

			else

				render :template => "theme/#{current_theme}/page.html.erb"

			end

		end	

	end

	def show_url(params)

		post = Post.find(params[:id])
 		article_url = Setting.get('articles_slug')
 		@url = ''
 		
 		if post.post_type == 'post'
 			@url = "/#{article_url}/#{post.post_slug}"
 		end

 		@url += "#{post.structured_url}"

 		return @url

	end


	def route_dynamic_page(params)

		segments = params[:slug].split('/')
		url = params[:slug]
		article_url = Setting.get('articles_slug')
		category_url = Setting.get('category_slug')	
		tag_url = Setting.get('tag_slug')

		if !session[:admin_id].blank?

			status = "(post_status = 'Published')"

		else

			status = "(post_status = 'Published' AND post_date <= CURRENT_TIMESTAMP()"

		end

		if segments[0] == article_url

			if !segments[1].blank?
				if segments[1] == category_url
					
					render_category segments, article_url, true, status

				elsif segments[1] == tag_url

					render_category segments, article_url, true, status

				elsif segments[1].nonnegative_float?

					render_archive segments, article_url

				else

					render_single segments, article_url, status

				end

			else
				render_category segments, article_url, status
			end

		else<commit_msg>updates to the sql<commit_after>module RoutingHelper

	def route_index_page(params)

		if !params[:search].blank?
			gloalize Post.where("(post_title LIKE :p or post_slug LIKE :p2 or post_content LIKE :p3) and (post_type != 'autosave')", {:p => "%#{params[:search]}%", :p2 => "%#{params[:search]}%", :p3 => "%#{params[:search]}%"})
			add_breadcrumb "Home", :root_path, :title => "Home"
			add_breadcrumb "Search", "/"
			render :template => "theme/#{current_theme}/search"

		else

			home_id = Setting.get('home_page')	
			@content = Post.find(home_id)
			gloalize @content
			render_template 'home'
		end


	end

	def render_template(default)



		if !@content.post_template.blank?

			if File.exists?("app/views/theme/#{current_theme}/template-#{@content.post_template.downcase}.html.erb")

				render :template => "theme/#{current_theme}/template-#{@content.post_template.downcase}"

			else

				if File.exists?("app/views/theme/#{current_theme}/#{default}.html.erb")	

					render :template => "theme/#{current_theme}/#{default}"
				else 

					render :template => "theme/#{current_theme}/page.html.erb"

				end

			end

		else

			if File.exists?("app/views/theme/#{current_theme}/#{default}.html.erb")

				render :template => "theme/#{current_theme}/#{default}"

			else

				render :template => "theme/#{current_theme}/page.html.erb"

			end

		end	

	end

	def show_url(params)

		post = Post.find(params[:id])
 		article_url = Setting.get('articles_slug')
 		@url = ''
 		
 		if post.post_type == 'post'
 			@url = "/#{article_url}/#{post.post_slug}"
 		end

 		@url += "#{post.structured_url}"

 		return @url

	end


	def route_dynamic_page(params)

		segments = params[:slug].split('/')
		url = params[:slug]
		article_url = Setting.get('articles_slug')
		category_url = Setting.get('category_slug')	
		tag_url = Setting.get('tag_slug')

		if !session[:admin_id].blank?

			status = "(post_status = 'Published')"

		else

			status = "(post_status = 'Published' AND post_date <= NOW())"

		end

		if segments[0] == article_url

			if !segments[1].blank?
				if segments[1] == category_url
					
					render_category segments, article_url, true, status

				elsif segments[1] == tag_url

					render_category segments, article_url, true, status

				elsif segments[1].nonnegative_float?

					render_archive segments, article_url

				else

					render_single segments, article_url, status

				end

			else
				render_category segments, article_url, status
			end

		else
{'fraction_non_alphanumeric': 0.15302847974328118, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 3.7314990512333965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '2619144', 'n_tokens_mistral': 2046, 'n_tokens_neox': 1702, 'n_words': 330}