Skip to content

Commit 4f3899f

Browse files
committed
autopublish on the hourly basis and ui cleanup
1 parent c02505f commit 4f3899f

File tree

17 files changed

+187
-50
lines changed

17 files changed

+187
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ or
5656

5757
### ~~Stories have WYSIWYG editing with full html capability~~
5858

59-
### Stories can be set to be auto or prepublished (variables set, validations in progress)
59+
### ~~Stories can be set to be auto or prepublished (variables set, validations in progress)~~
6060

6161
### ~~Require user to make journalist account in order to create or edit a story and require user to have journalist account with editor status to manage themes, newspaper settings, admin, etc~~
6262

app/assets/stylesheets/app.scss

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ $maxwidth: 1920px;
88
// mnml defaults //
99

1010
*, html {
11-
font-family: sans-serif;
1211
text-decoration: none;
1312
}
1413

@@ -167,6 +166,7 @@ nav a {
167166
margin: 1rem;
168167
text-align: center;
169168
flex-grow: 2;
169+
font-size: 2rem;
170170
}
171171

172172
// Headlines //
@@ -178,16 +178,16 @@ h1 {
178178
}
179179

180180
h2 {
181-
font-size: 3rem;
181+
font-size: 4rem;
182182
@media only screen and (max-width: $maxwidth) {
183183
font-size: 3vw;
184184
}
185185
}
186186

187187
h3 {
188-
font-size: 1.5rem;
188+
font-size: 3rem;
189189
@media only screen and (max-width: $maxwidth) {
190-
font-size: 1.5vw;
190+
font-size: 1.75vw;
191191
}
192192
}
193193

@@ -213,23 +213,15 @@ h3 {
213213
width: 100%;
214214
}
215215

216-
.covertext {
217-
font-size: 2rem;
218-
}
219-
220216
.videocard {
221217
display: inline-flex;
222-
.videowrapper {
223-
width: 73%;
224-
padding: 1%;
225-
}
226218
.videopane {
227-
width: 33%;
219+
width: 98%;
228220
padding: 1%;
229221
}
230222
@media only screen and (max-width: $maxwidth) {
231223
.covertext {
232-
font-size: 1.5vw;
224+
font-size: 2vw;
233225
}
234226
}
235227
}
@@ -242,6 +234,21 @@ h3 {
242234
}
243235
}
244236

237+
.audiocard {
238+
@media only screen and (max-width: $maxwidth) {
239+
.covertext {
240+
font-size: 2vw;
241+
}
242+
}
243+
}
244+
.textcard {
245+
@media only screen and (max-width: $maxwidth) {
246+
.covertext {
247+
font-size: 2vw;
248+
}
249+
}
250+
}
251+
245252

246253
#toolbar {
247254
display: inline-block;

app/controllers/home_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'date'
12
class HomeController < ApplicationController
23
before_action :authenticate_user!, only: [:dashboard]
34
def index

app/controllers/stories_controller.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ def only_journalists
1313

1414
# GET /stories or /stories.json
1515
def index
16-
@stories = Story.all.published
16+
Story.to_be_published.each do |s|
17+
puts s.title + " | " + s.autopublishdate.to_s
18+
s.autopublish if DateTime.now > s.autopublishdate
19+
end
20+
@stories = Story.published
21+
end
22+
23+
def drafts
24+
@stories = Story.drafts
1725
end
1826

1927
# GET /stories/1 or /stories/1.json
@@ -54,8 +62,11 @@ def update
5462
respond_to do |format|
5563
if @story.update(story_params)
5664

65+
if @story.publish == false
66+
@story.publishdate = nil
67+
@story.save!
5768
#sets the publish date of a news story to day it was first published. (saved with publish = true)
58-
if @story.publish? && @story.publishdate.nil?
69+
elsif @story.publish && @story.publishdate.nil?
5970
@story.publishdate = DateTime.now
6071
@story.save
6172
end

app/models/story.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ class Story < ApplicationRecord
1212

1313
scope :published, -> {where(publish: true)}
1414
scope :to_be_published, -> {where(enableautopublish: true)}
15+
scope :drafts, -> {where(publish: false)}
1516

1617
def autopublish
1718
if DateTime.now >= self.autopublishdate
1819
self.publish = true
1920
self.publishdate = self.autopublishdate
21+
self.enableautopublish = false #disable after successful run
2022
self.save!
2123
end
2224
end

app/views/categories/_category.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div id="<%= dom_id category %>">
2+
<!-- OLD
23
<p>
34
<strong>Name:</strong>
45
<%= category.name %>
@@ -8,5 +9,7 @@
89
<strong>Color:</strong>
910
<%= category.color %>
1011
</p>
12+
-->
13+
<a href="categories/<%= category.id %>/edit" style="text-decoration: none; border: none; border-bottom: 2px solid; border-color: <%= category.color %>; order: <%= category.order %>; padding: 2em;"><%= category.name.upcase + " & order: " + category.order.to_s %></a>
1114

1215
</div>

app/views/categories/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<div class="field">
2525
<%= form.label :order, style: "display: block" %>
26-
<%= form.number_field :order %>
26+
<%= form.number_field :order, min: "0" %>
2727
</div>
2828

2929
<div>
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<p style="color: green"><%= notice %></p>
22

3-
<h1>Categories</h1>
3+
<h1>Categories | <%= link_to "New", new_category_path %></h1>
44

5-
<div id="categories">
5+
<div style="display: inline;" id="categories">
66
<% @categories.each do |category| %>
7-
<%= render category %>
8-
<p>
9-
<%= link_to "Show this category", category %>
10-
</p>
7+
<div style="padding: 2rem;"><%= render category %></div>
118
<% end %>
12-
</div>
13-
14-
<%= link_to "New category", new_category_path %>
9+
</div>

app/views/home/dashboard.html.erb

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,40 @@
22
<p style="padding: 3rem;">“The basis of our governments being the opinion of the people, the very first object should be to keep that right; and were it left to me to decide whether we should have a government without newspapers, or newspapers without a government, I should not hesitate a moment to prefer the latter.” – Thomas Jefferson</p>
33

44
<!-- IF USER IS EDITOR? -->
5-
<h2>Settings</h2>
5+
<h2>Settings | <%= link_to "Edit", edit_setting_path(@setting) %></h2>
66
<% if @setting.nil? %>
77
<%= link_to "New Settings", new_setting_path %>
88
<% else %>
9-
<label>Name & Tagline:</label>
10-
<h3><%= @setting.newspapername %></h3>
11-
<em><%= @setting.tagline %></em>
9+
<label>Name</label>
10+
<blockquote><h1><%= @setting.newspapername %></h1></blockquote>
11+
<label>Tagline</label>
12+
<blockquote><h2><%= @setting.tagline %></h2></blockquote>
1213
<br/>
1314
<br/>
14-
<label>Current Theme: <%= @setting.theme.name %></label>
15+
<label>Current Theme:</label>
16+
<blockquote><h3><%= @setting.theme.name %></h3></blockquote>
1517
<br/>
1618
<br/>
17-
<%= link_to "Edit Settings", edit_setting_path(@setting) %>
1819
<% end %>
1920

20-
<h2>Themes</h2>
21+
<h2>Themes | <%= link_to "New", new_theme_path %></h2>
2122
<% unless @themes.nil? %>
2223
<% @themes.each do |theme| %>
24+
<div style="padding: 2em;">
2325
<%= link_to theme.name, edit_theme_path(theme) %>
26+
<br/>
27+
<div style="font-size: 4rem;">
28+
<span style="color: <%= theme.backgroundcolor %>"></span><span style="color: <%= theme.headingcolor %>"></span><span style="color: <%= theme.textcolor %>"></span><span style="color: <%= theme.primarycolor %>"></span><span style="color: <%= theme.secondarycolor %>"></span><span style="color: <%= theme.tertiarycolor %>"></span><span style="color: <%= theme.quaternarycolor %>"></span>
29+
</div>
30+
<% if theme.logo.attached? %>
31+
<img style="max-height: 200px; width: auto;" src="<%= url_for(theme.logo) %>">
32+
<% end %>
33+
</div>
2434
<% end %>
2535
<% end %>
26-
<br/><br/>
27-
<%= link_to "New Theme", new_theme_path %>
2836
<br/>
2937
<br/>
30-
<h2>Categories</h2>
38+
<h2>Categories | <%= link_to "New", new_category_path %></h2>
3139
<div style="display: inline-flex;">
3240
<% unless Category.nil? %>
3341
<% Category.all.each do |category| %>
@@ -36,13 +44,11 @@
3644
<% end %>
3745
</div>
3846
<br/><br/>
39-
<%= link_to "New Category", new_category_path %>
4047
<!-- END IF USER IS EDITOR? -->
4148

42-
<h2>Stories</h2>
49+
<h2>Stories | <%= link_to "New", new_story_path %></h2>
4350
<% unless Story.nil? %>
4451
<% Story.all.each do |story| %>
4552
<h5><%= unless story.publish? then "Draft: " end %><a href="stories/<%= story.slug %>"><%= story.title %></a> | <a href="stories/<%= story.slug %>/edit">EDIT</a></h5>
4653
<% end %>
4754
<% end %>
48-
<%= link_to "New Story", new_story_path %>

app/views/home/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1 style="text-align: right;"><%= Date.today.strftime("%A, %B %e %Y") %></h1>
1+
<h1 style="text-align: right;"><%= DateTime.now.strftime("%A, %B, %d, %Y %l:%M %P") %></h1>
22
<h2>
33
<% if Setting.last.nil? %>
44
All The News. All The Time.

0 commit comments

Comments
 (0)