mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
continued work on site profile, tag adding
This commit is contained in:
parent
264e4becea
commit
d9b33238e9
10 changed files with 110 additions and 14 deletions
9
app.rb
9
app.rb
|
@ -214,6 +214,13 @@ post '/site/:site_id/toggle_follow' do |site_id|
|
|||
{result: (current_site.toggle_follow(site) ? 'followed' : 'unfollowed')}.to_json
|
||||
end
|
||||
|
||||
post '/tags/add' do
|
||||
require_login
|
||||
current_site.new_tags = params[:tags]
|
||||
current_site.save validate: false
|
||||
redirect request.referer
|
||||
end
|
||||
|
||||
get '/browse' do
|
||||
@current_page = params[:current_page]
|
||||
@current_page = @current_page.to_i
|
||||
|
@ -899,7 +906,7 @@ post '/event/:event_id/delete' do |event_id|
|
|||
content_type :json
|
||||
event = Event[id: event_id]
|
||||
|
||||
if event.site_id == current_site.id || event.owned_by?(current_site)
|
||||
if event.site_id == current_site.id || event.created_by?(current_site)
|
||||
event.delete
|
||||
return {result: 'success'}.to_json
|
||||
end
|
||||
|
|
5
ext/NilClass.rb
Normal file
5
ext/NilClass.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class NilClass
|
||||
def empty?
|
||||
true
|
||||
end
|
||||
end
|
5
ext/string.rb
Normal file
5
ext/string.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class String
|
||||
def empty?
|
||||
strip == '' ? true : false
|
||||
end
|
||||
end
|
11
migrations/030_fix_event_timestamp.rb
Normal file
11
migrations/030_fix_event_timestamp.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.drop_column :events, :created_at
|
||||
DB.add_column :events, :created_at, :timestamp, index: true
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_column :events, :created_at
|
||||
DB.add_column :events, :created_at, :integer, index: true
|
||||
}
|
||||
end
|
|
@ -13,7 +13,7 @@ class Event < Sequel::Model
|
|||
many_to_one :actioning_site, key: :actioning_site_id, class: :Site
|
||||
|
||||
def created_by?(site)
|
||||
return true if profile_comment && profile_comment.actioning_site_id == site.id
|
||||
return true if actioning_site_id == site.id
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -279,12 +279,18 @@ class Site < Sequel::Model
|
|||
def after_save
|
||||
if @new_tag_strings
|
||||
@new_tag_strings.each do |new_tag_string|
|
||||
add_tag Tag[name: new_tag_string] || Tag.create(name: new_tag_string)
|
||||
add_tag_name new_tag_string
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def add_tag_name(name)
|
||||
if tags_dataset.filter(name: name).first.nil?
|
||||
add_tag Tag[name: name] || Tag.create(name: name)
|
||||
end
|
||||
end
|
||||
|
||||
def after_create
|
||||
DB['update servers set slots_available=slots_available-1 where id=?', self.server.id].first
|
||||
super
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<div class="news-item follow">
|
||||
<div class="title">
|
||||
<div class="icon"></div>
|
||||
<a href="/site/<%= event.actioning_site.username %>" class="user"><%= event.actioning_site.username %></a> followed <a href="/site/<%= event.site.username %>" class="user"><%= event.site.username %>'s</a> website<span class="date">7h</span>
|
||||
<a href="/site/<%= event.actioning_site.username %>" class="user"><%= event.actioning_site.username %></a> followed <a href="/site/<%= event.site.username %>" class="user"><%= event.site.username %>'s</a> website<span class="date"><%= event.created_at.ago %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
<% end %>
|
||||
<% if current_site %>
|
||||
<a id="reply" href="#" onclick="Template.renderComment(<%= event.id %>); return false">Reply</a>
|
||||
<% if event.created_by? current_site %>
|
||||
<% if event.profile_comment_id %>
|
||||
<% if event.profile_comment_id && event.created_by?(current_site) %>
|
||||
<a id="editLink" href="#" onclick="ProfileComment.displayEditor('<%= event.id %>'); return false">Edit</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if event.created_by?(current_site) || event.site_id == current_site.id %>
|
||||
<a href="#" onclick="Event.delete(<%= event.id %>, '<%= csrf_token %>'); return false">Delete</a>
|
||||
|
|
|
@ -1,10 +1,37 @@
|
|||
<% if (!is_current_site && site.tags_dataset.count > 0) || is_current_site %>
|
||||
<h3>Tags</h3>
|
||||
<% if site.tags_dataset.count == 0 %>
|
||||
<p>You don't have any tags yet. <a href="#">Add some!</a>
|
||||
<% if is_current_site && site.tags_dataset.count == 0 %>
|
||||
<p>You don't have any tags yet. <a href="#addTag" data-toggle="modal">Add some!</a>
|
||||
<% else %>
|
||||
<% site.tags.each do |tag| %>
|
||||
<a class="tag" href="/browse?tag=<%== Rack::Utils.escape tag.name %>"><%= tag.name %></a>
|
||||
<% end %>
|
||||
|
||||
<% if is_current_site %>
|
||||
<div class="clear">
|
||||
<a href="#addTag" data-toggle="modal">Add Tags</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="modal hide fade" id="addTag" tabindex="-1" role="dialog" aria-labelledby="addTagLabel" aria-hidden="true">
|
||||
<form method="POST" action="/tags/add">
|
||||
<input type="hidden" value="<%= csrf_token %>" name="csrf_token">
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
<h3 id="addTagLabel">Add Tags</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
Tags must only be a single word, and can only contain letters and numbers. Separate multiple tags with commas (example: pokemon, gardening, bicycles).
|
||||
</p>
|
||||
<p>Tags:</p>
|
||||
<input type="text" name="tags">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
<button type="submit" class="btn btn-Action">Add Tag(s)</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
|
@ -33,7 +33,7 @@
|
|||
</a>
|
||||
<a href="#" class="btn-Action tip"><span>Tip</span></a>
|
||||
<% end %>
|
||||
<a href="#" class="btn-Action share" onclick="$('#shareModal').modal(); return false"><span>Share</span></a>
|
||||
<!-- <a href="#" class="btn-Action share" onclick="$('#shareModal').modal(); return false"><span>Share</span></a> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -79,6 +79,28 @@
|
|||
<div class="stat"><span>Created</span><strong><%= site.created_at.strftime('%B %-d, %Y') %></strong></div>
|
||||
</div>
|
||||
|
||||
<%== erb :'_follows', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||
|
||||
<h3><i class="fa fa-share-alt"></i> Share</h3>
|
||||
<div>
|
||||
<p>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-text="<%= site.username %>.neocities.org is awesome!" data-via="neocitiesweb" data-url="http://<%= site.username %>.neocities.org" data-count="none">Tweet</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span id="tumblr_button_abc123"></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent('http://<%= site.username %>.neocities.org'); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<div class="fb-share-button" data-href="http://<%= site.username %>.neocities.org" data-width="100" data-type="button" style="height: 100px"></div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<h3>Archives</h3>
|
||||
<div class="archives">
|
||||
|
@ -90,8 +112,6 @@
|
|||
</div>
|
||||
-->
|
||||
|
||||
<%== erb :'_follows', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||
|
||||
<%== erb :'_tags', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||
|
||||
<div class="report">
|
||||
|
@ -101,12 +121,28 @@
|
|||
</div></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var tumblr_link_url = "http://<%= site.username %>.neocities.org"
|
||||
var tumblr_link_name = "<%= site.username %>.neocities.org"
|
||||
var tumblr_link_description = "<%= site.username %>.neocities.org"
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var tumblr_button = document.createElement("a");
|
||||
tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
|
||||
tumblr_button.setAttribute("title", "Share on Tumblr");
|
||||
tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:61px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
|
||||
tumblr_button.innerHTML = "Share on Tumblr";
|
||||
document.getElementById("tumblr_button_abc123").appendChild(tumblr_button);
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<div class="modal hide fade" id="shareModal" tabindex="-1" role="dialog" aria-labelledby="shareModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
<h3 id="shareModalLabel">Share this Site</h3>
|
||||
</div>
|
||||
<div class="modal-body" style="height: 300px">
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-text="<%= site.username %>.neocities.org is awesome!" data-via="neocitiesweb" data-count="none">Tweet</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
|
@ -128,3 +164,4 @@
|
|||
<button class="btn" data-dismiss="modal" aria-hidden="true">Done</button>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
Loading…
Add table
Reference in a new issue