Skip to content
This repository
  • 2 commits
  • 12 files changed
  • 0 comments
  • 1 contributor
4 app/assets/stylesheets/app_bootstrap.css.scss
@@ -33,5 +33,9 @@ $baseLineHeight: 18px;
33 33 }
34 34 }
35 35
  36 +.select-datetime {
  37 + width: 70px;
  38 +}
  39 +
36 40 @import "twitter/bootstrap";
37 41 @import "twitter/bootstrap-responsive";
2  app/controllers/articles_controller.rb
@@ -8,7 +8,7 @@ class ArticlesController < ApplicationController
8 8 def index
9 9 relation = apply_scopes(Article.accessible_by(current_ability))
10 10 @articles = ArticleQuery.new(relation).list.page(params[:page])
11   - set_meta_tags title: I18n.t(:articles)
  11 + set_meta_tags title: I18n.t(:articles_title)
12 12 end
13 13
14 14 def new
4 app/models/article.rb
... ... @@ -1,7 +1,7 @@
1 1 class Article < ActiveRecord::Base
2 2 CUTTER = "&lt;cut&gt;"
3 3
4   - attr_accessible :title, :body, :views_count, :tag_list, :published, :published_on
  4 + attr_accessible :title, :body, :views_count, :tag_list, :published, :published_at
5 5
6 6 acts_as_commentable
7 7 acts_as_taggable
@@ -21,6 +21,6 @@ def self.top_tags(count)
21 21
22 22 private
23 23 def init_defaults
24   - self.published_on ||= created_at.presence.try(:to_date) || Date.current
  24 + self.published_at ||= created_at.presence || DateTime.current
25 25 end
26 26 end
2  app/models/article_query.rb
@@ -4,6 +4,6 @@ def initialize(relation = Article)
4 4 end
5 5
6 6 def list
7   - @relation.order("published_on DESC").scoped
  7 + @relation.order("published_at DESC").scoped
8 8 end
9 9 end
2  app/models/legacy/news.rb
@@ -16,7 +16,7 @@ def self.import(legacy_id)
16 16 article.user_id = user.id
17 17 article.views_count = legacy.hits or 0
18 18 article.created_at = legacy.created_at or DateTime.current
19   - article.published_on = legacy.created_at or DateTime.current
  19 + article.published_at = legacy.created_at or DateTime.current
20 20 article.updated_at = legacy.modified_at or DateTime.current
21 21 article.ip_address = legacy.ip_address
22 22
6 app/views/articles/_article.html.haml
@@ -16,7 +16,7 @@
16 16 = link_to user_path(article.user) do
17 17 = article.user_name || article.user_email
18 18 = " @"
19   - = l article.published_on, format: :long
  19 + = l article.published_at, format: :long
20 20
21 21 .article-body
22 22 = raw formatted(article.body, params[:action] == "index")
@@ -33,8 +33,4 @@
33 33 = "|"
34 34 = t("articles.meta.views_count", :views_count => article.views_count)
35 35 .spacer
36   - %br
37   - -# .fb-like(data-href="#{article_url(article)}" data-send="false" data-layout="button_count" data-width="20" data-show-faces="false")
38   - -# %a.twitter-share-button(href="https://twitter.com/share" data-url="#{article_url(article)}" data-text="#{article.title}")
39   - -# Tweet
40 36 %hr
2  app/views/articles/_form.html.haml
@@ -3,7 +3,7 @@
3 3 = f.input :title
4 4 = f.input :body, as: :ckeditor
5 5 = f.input :tag_list, hint: t(:tags_hint)
6   - = f.input :published_on, input_html: { class: "span2" }, label: Article.human_attribute_name(:published_on)
  6 + = f.input :published_at, input_html: { class: "select-datetime" }, label: Article.human_attribute_name(:published_at)
7 7 = f.input :published, inline_label: true
8 8
9 9 = render 'hint'
2  config/locales/models/article.ru.yml
@@ -7,5 +7,5 @@ ru:
7 7 article:
8 8 title: Заголовок
9 9 body: Содержимое новости
10   - published_on: Дата публикации
  10 + published_at: Дата публикации
11 11 published: Опубликована
1  config/locales/ru.yml
@@ -91,4 +91,5 @@ ru:
91 91 new_page: Новая страница
92 92 create_page: Создать страницу
93 93 pages: Страницы
  94 + articles_title: Новости
94 95
2  db/migrate/20130310104710_add_published_to_articles.rb
@@ -2,6 +2,6 @@ class AddPublishedToArticles < ActiveRecord::Migration
2 2 def change
3 3 add_column :articles, :published, :boolean, default: true
4 4 add_index :articles, :published
5   - add_column :articles, :published_on, :date
  5 + add_column :articles, :published_at, :datetime
6 6 end
7 7 end
2  db/schema.rb
@@ -23,7 +23,7 @@
23 23 t.string "ip_address"
24 24 t.integer "legacy_id"
25 25 t.boolean "published", :default => true
26   - t.date "published_on"
  26 + t.datetime "published_at"
27 27 end
28 28
29 29 add_index "articles", ["ip_address"], :name => "index_articles_on_ip_address"
4 spec/factories/articles.rb
@@ -17,11 +17,11 @@
17 17 end
18 18
19 19 factory :old_article do
20   - published_on { 10.days.ago }
  20 + published_at { 10.days.ago }
21 21 end
22 22
23 23 factory :very_old_article do
24   - published_on { 20.days.ago }
  24 + published_at { 20.days.ago }
25 25 end
26 26
27 27 factory :unpublished_article, traits: [:unpublished]

No commit comments for this range

Something went wrong with that request. Please try again.