mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
fix news feed display, notifications, fix tag create
This commit is contained in:
parent
7f5f028cc5
commit
47dde508d3
4 changed files with 34 additions and 6 deletions
4
app.rb
4
app.rb
|
@ -248,6 +248,8 @@ get '/?' do
|
|||
@page_count = events_dataset.page_count || 1
|
||||
@events = events_dataset.all
|
||||
|
||||
current_site.events_dataset.update notification_seen: true
|
||||
|
||||
halt erb :'home', locals: {site: current_site}
|
||||
end
|
||||
|
||||
|
@ -362,7 +364,7 @@ post '/tags/add' do
|
|||
current_site.new_tags_string = params[:tags]
|
||||
|
||||
if current_site.valid?
|
||||
current_site.save_changes
|
||||
current_site.save_tags
|
||||
else
|
||||
flash[:errors] = current_site.errors.first
|
||||
end
|
||||
|
|
|
@ -244,6 +244,14 @@ class Site < Sequel::Model
|
|||
super val.downcase
|
||||
end
|
||||
|
||||
def unseen_notifications_dataset
|
||||
events_dataset.where notification_seen: false
|
||||
end
|
||||
|
||||
def unseen_notifications_count
|
||||
@unseen_notifications_count ||= unseen_notifications_dataset.count
|
||||
end
|
||||
|
||||
def valid_password?(plaintext)
|
||||
valid = BCrypt::Password.new(owner.values[:password]) == plaintext
|
||||
|
||||
|
@ -590,6 +598,11 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def after_save
|
||||
save_tags
|
||||
super
|
||||
end
|
||||
|
||||
def save_tags
|
||||
if @new_filtered_tags
|
||||
@new_filtered_tags.each do |new_tag_string|
|
||||
add_tag_name new_tag_string
|
||||
|
@ -597,7 +610,6 @@ class Site < Sequel::Model
|
|||
@new_filtered_tags = []
|
||||
@new_tags_string = nil
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def add_tag_name(name)
|
||||
|
|
|
@ -34,10 +34,24 @@
|
|||
</li>
|
||||
<% else %>
|
||||
<li class="dropdown">
|
||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= current_site.username %> <span class="info"><span class="notification-value">3</span><i class="fa fa-caret-down"></i></span></a>
|
||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle">
|
||||
<%= current_site.username %>
|
||||
<span class="info">
|
||||
<% if current_site.unseen_notifications_count > 0 %>
|
||||
<span class="notification-value"><%= current_site.unseen_notifications_count %></span>
|
||||
<% end %>
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/site/<%= current_site.username %>">Profile</a></li>
|
||||
<li><a href="/?activity=mine">Activity <span class="notification-value">3</span></a></li>
|
||||
<li>
|
||||
<a href="/?activity=mine">Activity
|
||||
<% if current_site.unseen_notifications_count > 0 %>
|
||||
<span class="notification-value"><%= current_site.unseen_notifications_count %></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/dashboard">Edit Site</a></li>
|
||||
<li><a href="//<%= current_site.host %>" target="_blank">View Site</a></li>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="col col-66">
|
||||
<h3>Your Feed</h3>
|
||||
<div class="feed-filter">
|
||||
<% if current_site.followings_dataset.count > 0 %>
|
||||
<% if !@events.empty? %>
|
||||
<a href="/" <% if params[:activity] != 'mine' %>class="selected"<% end %>>All Activity</a>
|
||||
|
||||
<a href="/?activity=mine" <% if params[:activity] == 'mine' %>class="selected"<% end %>>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<div class="content misc-page columns right-col">
|
||||
<div class="col-left">
|
||||
<div class="col col-66">
|
||||
<% if current_site.followings_dataset.count > 0 %>
|
||||
<% if !@events.empty? %>
|
||||
<%== erb :'_news', layout: false, locals: {site: current_site, events: @events} %>
|
||||
<% else %>
|
||||
<div class="welcome">
|
||||
|
|
Loading…
Add table
Reference in a new issue