<commit_before>class Spud::Admin::PagesController < Spud::Admin::ApplicationController
	layout 'spud/admin/cms/detail'
	add_breadcrumb "Pages", :spud_admin_pages_path
	before_filter :load_page,:only => [:edit,:update,:show,:destroy]
	
	def index
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "Pages"
		@pages = SpudPage.where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page]
	end

	def show
	end

	def new
		add_breadcrumb "New", :new_spud_admin_page_path

		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "New Page"
		@templates = SpudTemplate.all
		@page = SpudPage.new
		@page.spud_page_partials.new(:name => "Body")
		# @page.spud_page_partials.new(:name => "Sidebar")
	end

	def create
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "New Page"
		@page = SpudPage.new(params[:spud_page])
		
		if @page.save
			flash[:notice] = "Page Saved successfully"
			redirect_to spud_admin_pages_url() and return
		else
			flash[:error] = "Error creating page"
			@error_object_name = "page"
			render :action => "new"
		end
	end

	def edit
		add_breadcrumb "#{@page.name}", :spud_admin_page_path
		add_breadcrumb "Edit", :edit_spud_admin_page_path
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "Edit Page"
		@templates = SpudTemplate.all
		if @page.spud_page_partials.blank?
			@page.spud_page_partials.new(:name => "Body")
		end
	end

	def update
		if @page.update_attributes(params[:spud_page])
			flash[:notice] = "Page updated successfully!"
			redirect_to spud_admin_pages_url() and return
		else
			flash[:error] = "There was an error saving this page"
			render :action => "edit"
		end

	end

	def destroy
		status = 500
		if @page.destroy
			flash[:notice] = "Page removed successfully!"
			status = 200
		else
			flash[:error] = "Error removing page"
		end
		respond_to do |format|
			format.js {render :status => status}<commit_msg>fixed initialization of page partials<commit_after>class Spud::Admin::PagesController < Spud::Admin::ApplicationController
	layout 'spud/admin/cms/detail'
	add_breadcrumb "Pages", :spud_admin_pages_path
	before_filter :load_page,:only => [:edit,:update,:show,:destroy]
	
	def index
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "Pages"
		@pages = SpudPage.where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page]
	end

	def show
	end

	def new
		add_breadcrumb "New", :new_spud_admin_page_path

		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "New Page"
		@templates = SpudTemplate.all
		@page = SpudPage.new
		@page.spud_page_partials.new(:name => "Body")
		# @page.spud_page_partials.new(:name => "Sidebar")
	end

	def create
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "New Page"
		@page = SpudPage.new(params[:spud_page])
		
		if @page.save
			flash[:notice] = "Page Saved successfully"
			redirect_to spud_admin_pages_url() and return
		else
			flash[:error] = "Error creating page"
			@error_object_name = "page"
			render :action => "new"
		end
	end

	def edit
		add_breadcrumb "#{@page.name}", :spud_admin_page_path
		add_breadcrumb "Edit", :edit_spud_admin_page_path
		@page_thumbnail = "spud/admin/pages_thumb.png"
		@page_name = "Edit Page"
		@templates = SpudTemplate.all
		if @page.spud_page_partials.blank?
			@page.spud_page_partials.new(:name => "Body")
		end
		if !@page.spud_template.blank?
			@page.spud_template.page_parts.split(",").each do |part|
				partial = @page.spud_page_partials.select{|p| p.name == part}
				if partial.blank?
					@page.spud_page_partials.new(:name => part)
				end
			end
		end
	end

	def update
		if @page.update_attributes(params[:spud_page])
			flash[:notice] = "Page updated successfully!"
			redirect_to spud_admin_pages_url() and return
		else
			flash[:error] = "There was an error saving this page"
			render :action => "edit"
		end

	end

	def destroy
		status = 500
		if @page.destroy
			flash[:notice] = "Page removed successfully!"
			status = 200
		else
			flash[:error] = "Error removing page"
		end
		respond_to do |format|
			format.js {render :status => status}
{'fraction_non_alphanumeric': 0.12790419161676647, 'fraction_numerical': 0.002874251497005988, 'mean_word_length': 4.487516425755585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '244929', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1513, 'n_words': 315}