Sha256: 182942ce5c3dd42026cb6691cbd924738ed7f076556e72eec95127c22be10695

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 KB

Contents

require_dependency "writefully/application_controller"

module Writefully
  class SitesController < ApplicationController
    before_filter :authenticate_wf_authorship!

    VALID_TABS = %w(processing errors)

    def index
      @sites = current_wf_authorship.owned_sites
      redirect_to new_site_path if @sites.empty?
    end

    def show
      @site = get_site
      if params[:tab].nil? or not tab_valid?
        redirect_to site_posts_path(@site) 
      end
    end

    def new
      @site = current_wf_authorship.owned_sites.build
    end

    def edit
      @site = get_site
    end

    def create
      @site = current_wf_authorship.owned_sites.build(site_params)
      if @site.save
        set_flash :success, object: @site
        redirect_to sites_path
      end
    end

  protected

    def tab_valid?
      VALID_TABS.include?(params[:tab])
    end

    def get_site
      current_wf_authorship.owned_sites.friendly.find(params[:id])
    end

    def site_params
      params.require(:site).permit(:name, :domain)
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
writefully-0.8.2 app/controllers/writefully/sites_controller.rb
writefully-0.8.1 app/controllers/writefully/sites_controller.rb
writefully-0.8.0 app/controllers/writefully/sites_controller.rb
writefully-0.7.1 app/controllers/writefully/sites_controller.rb
writefully-0.6.12 app/controllers/writefully/sites_controller.rb
writefully-0.6.11 app/controllers/writefully/sites_controller.rb
writefully-0.6.10 app/controllers/writefully/sites_controller.rb
writefully-0.6.9 app/controllers/writefully/sites_controller.rb
writefully-0.6.7 app/controllers/writefully/sites_controller.rb
writefully-0.6.6 app/controllers/writefully/sites_controller.rb
writefully-0.6.5 app/controllers/writefully/sites_controller.rb
writefully-0.6.4 app/controllers/writefully/sites_controller.rb
writefully-0.6.3 app/controllers/writefully/sites_controller.rb
writefully-0.6.2 app/controllers/writefully/sites_controller.rb
writefully-0.5.1 app/controllers/writefully/sites_controller.rb
writefully-0.5.0 app/controllers/writefully/sites_controller.rb
writefully-0.4.10 app/controllers/writefully/sites_controller.rb
writefully-0.4.8 app/controllers/writefully/sites_controller.rb
writefully-0.4.7 app/controllers/writefully/sites_controller.rb
writefully-0.4.6 app/controllers/writefully/sites_controller.rb