Class: Admin::BlogController

Inherits:
AdminCartoonistController
  • Object
show all
Defined in:
app/controllers/admin/blog_controller.rb

Instance Method Summary collapse

Instance Method Details

#archivesObject



5
6
7
8
# File 'app/controllers/admin/blog_controller.rb', line 5

def archives
  @posts = BlogPost.archives true
  render "blog/archives", :layout => "blog_archives"
end

#createObject



42
43
44
45
# File 'app/controllers/admin/blog_controller.rb', line 42

def create
  post = BlogPost.create_post current_user, params
  redirect_to "/admin/blog/#{post.id}/edit"
end

#editObject



47
48
49
50
51
# File 'app/controllers/admin/blog_controller.rb', line 47

def edit
  @post = BlogPost.find params[:id].to_i
rescue ActiveRecord::RecordNotFound
  redirect_to "/admin/blog/new"
end

#indexObject



37
38
39
40
# File 'app/controllers/admin/blog_controller.rb', line 37

def index
  @unposted = BlogPost.unposted.chronological
  @posted = BlogPost.posted.reverse_chronological
end

#lockObject



58
59
60
61
62
# File 'app/controllers/admin/blog_controller.rb', line 58

def lock
  post = BlogPost.find params[:id].to_i
  post.lock!
  redirect_to "/admin/blog/#{post.id}/edit"
end

#previewObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/admin/blog_controller.rb', line 10

def preview
  if params[:id].present?
    begin
      @post = BlogPost.preview_from_url_title params[:id]
    rescue
      redirect_to "/admin/blog/preview"
    end

    if @post.posted_at
      @disabled_next = @post.newest_preview?
    else
      @disabled_next = true
    end
  else
    @post = BlogPost.preview_current
    @title = "Blog for #{Setting[:site_name]}"
    @disabled_next = true
  end

  @disabled_prev = true if @post.oldest?
  render "blog/show", :layout => "blog"
end

#preview_contentObject



33
34
35
# File 'app/controllers/admin/blog_controller.rb', line 33

def preview_content
  render :text => Markdown.render(params[:content]), :layout => false
end

#unlockObject



64
65
66
67
68
# File 'app/controllers/admin/blog_controller.rb', line 64

def unlock
  post = BlogPost.find params[:id].to_i
  post.unlock!
  redirect_to "/admin/blog/#{post.id}/edit"
end

#updateObject



53
54
55
56
# File 'app/controllers/admin/blog_controller.rb', line 53

def update
  post = BlogPost.update_post params
  redirect_to "/admin/blog/#{post.id}/edit"
end