Class: Admin::DashboardController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/dashboard_controller.rb

Defined Under Namespace

Classes: RssItem

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#indexObject



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

def index
  today = Time.zone.now.strftime('%Y-%m-%d 00:00')

  # Since last visit
   = current_user.
  @newposts_count = Article.published_since().count
  @newcomments_count = Feedback.created_since().count

  # Today
  @statposts = Article.published.where('published_at > ?', today).count
  @statsdrafts = Article.drafts.where('created_at > ?', today).count
  @statspages = Page.where('published_at > ?', today).count
  @statuses = Note.where('published_at > ?', today).count
  @statuserposts = Article.published.where('published_at > ?', today).where(user_id: current_user.id).count
  @statcomments = Comment.where('created_at > ?', today).count
  @presumedspam = Comment.presumed_spam.where('created_at > ?', today).count
  @confirmed = Comment.ham.where('created_at > ?', today).count
  @unconfirmed = Comment.unconfirmed.where('created_at > ?', today).count

  @comments = Comment.last_published
  @drafts = Article.drafts.where('user_id = ?', current_user.id).limit(5)

  @statspam = Comment.spam.count
  @inbound_links = inbound_links
  publify_version
end

#publify_versionObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/admin/dashboard_controller.rb', line 35

def publify_version
  version = nil
  begin
    open(PUBLIFY_VERSION_URL) do |http|
      publify_version = http.read[0..5]
      version = publify_version.split('.')
    end
  rescue
    return
  end
  if version[0].to_i > TYPO_MAJOR.to_i
    flash[:error] = I18n.t('admin.dashboard.publify_version.error')
  elsif version[1].to_i > TYPO_SUB.to_i
    flash[:warning] = I18n.t('admin.dashboard.publify_version.warning')
  elsif version[2].to_i > TYPO_MINOR.to_i
    flash[:notice] = I18n.t('admin.dashboard.publify_version.notice')
  end
end