diff --git a/app/assets/javascripts/news.js b/app/assets/javascripts/news_updates.js
similarity index 67%
rename from app/assets/javascripts/news.js
rename to app/assets/javascripts/news_updates.js
index 9fba309c1..24d6ab0c2 100644
--- a/app/assets/javascripts/news.js
+++ b/app/assets/javascripts/news_updates.js
@@ -1,14 +1,14 @@
(function() {
- Danbooru.News = {};
+ Danbooru.NewsUpdate = {};
- Danbooru.News.initialize = function() {
- var key = $("#news-ticker").data("updated-at");
+ Danbooru.NewsUpdate.initialize = function() {
+ var key = $("#news-updates").data("updated-at");
if (Danbooru.Cookie.get("news-ticker") === key) {
- $("#news-ticker").hide();
+ $("#news-updates").hide();
} else {
$("#close-news-ticker-link").click(function(e) {
- $("#news-ticker").hide();
+ $("#news-updates").hide();
Danbooru.Cookie.put("news-ticker", key);
// need to reset the more link
@@ -20,6 +20,6 @@
}
$(function() {
- Danbooru.News.initialize();
+ Danbooru.NewsUpdate.initialize();
});
})();
diff --git a/app/assets/stylesheets/common/news.css.scss b/app/assets/stylesheets/common/news.css.scss
index 16b623cdf..8042b2338 100644
--- a/app/assets/stylesheets/common/news.css.scss
+++ b/app/assets/stylesheets/common/news.css.scss
@@ -1,4 +1,4 @@
-div#news-ticker {
+div#news-updates {
padding: 5px;
background: #EEE;
border-bottom: 2px solid #666;
diff --git a/app/assets/stylesheets/news_updates.css b/app/assets/stylesheets/news_updates.css
new file mode 100644
index 000000000..afad32db0
--- /dev/null
+++ b/app/assets/stylesheets/news_updates.css
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
diff --git a/app/controllers/news_updates_controller.rb b/app/controllers/news_updates_controller.rb
new file mode 100644
index 000000000..3680066e2
--- /dev/null
+++ b/app/controllers/news_updates_controller.rb
@@ -0,0 +1,38 @@
+class NewsUpdatesController < ApplicationController
+ before_filter :admin_only
+ respond_to :html
+
+ def index
+ @news_updates = NewsUpdate.paginate(params[:page])
+ respond_with(@news_updates)
+ end
+
+ def edit
+ @news_update = NewsUpdate.find(params[:id])
+ respond_with(@news_update)
+ end
+
+ def update
+ @news_update = NewsUpdate.find(params[:id])
+ @news_update.update_attributes(params[:news_update])
+ respond_with(@news_update, :location => news_updates_path)
+ end
+
+ def new
+ @news_update = NewsUpdate.new
+ respond_with(@news_update)
+ end
+
+ def create
+ @news_update = NewsUpdate.create(params[:news_update])
+ respond_with(@news_update, :location => news_updates_path)
+ end
+
+ def destroy
+ @news_update = NewsUpdate.find(params[:id])
+ @news_update.destroy
+ respond_with(@news_update) do |format|
+ format.js
+ end
+ end
+end
diff --git a/app/helpers/news_updates_helper.rb b/app/helpers/news_updates_helper.rb
new file mode 100644
index 000000000..ad303a632
--- /dev/null
+++ b/app/helpers/news_updates_helper.rb
@@ -0,0 +1,2 @@
+module NewsUpdatesHelper
+end
diff --git a/app/models/news_update.rb b/app/models/news_update.rb
new file mode 100644
index 000000000..9b844767d
--- /dev/null
+++ b/app/models/news_update.rb
@@ -0,0 +1,15 @@
+class NewsUpdate < ActiveRecord::Base
+ belongs_to :creator, :class_name => "User"
+ belongs_to :udpater, :class_name => "User"
+ scope :recent, order("created_at desc").limit(5)
+ before_validation :initialize_creator, :on => :create
+ before_validation :initialize_updater
+
+ def initialize_creator
+ self.creator_id = CurrentUser.id
+ end
+
+ def initialize_updater
+ self.updater_id = CurrentUser.id
+ end
+end
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 0058b85c5..9ce46e125 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -23,7 +23,7 @@
- <%= render "news/listing" %>
+ <%= render "news_updates/listing" %>
<%= link_to Danbooru.config.app_name, "/" %>