Merge branch 'v2' of github.com:neocities/neocities into v2

This commit is contained in:
Victoria Wang 2014-10-13 17:10:38 -07:00
commit 86a1d2dcac
4 changed files with 34 additions and 6 deletions

4
app.rb
View file

@ -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

View file

@ -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)

View file

@ -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>

View file

@ -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>
&nbsp;&nbsp;
<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">