mirror of
https://github.com/neocities/neocities.git
synced 2025-08-23 17:40:58 +02:00
initial profile comments
This commit is contained in:
parent
44311e4008
commit
5bc66e2524
11 changed files with 92 additions and 16 deletions
17
app.rb
17
app.rb
|
@ -70,7 +70,22 @@ end
|
||||||
get '/profile/:sitename' do |sitename|
|
get '/profile/:sitename' do |sitename|
|
||||||
@title = "#{sitename}.neocities.org"
|
@title = "#{sitename}.neocities.org"
|
||||||
site = Site[username: sitename]
|
site = Site[username: sitename]
|
||||||
erb :'profile', locals: {site: site}
|
erb :'profile', locals: {site: site, is_current_site: site == current_site}
|
||||||
|
end
|
||||||
|
|
||||||
|
post '/profile/:sitename/comment' do |sitename|
|
||||||
|
require_login
|
||||||
|
|
||||||
|
site = Site[username: sitename]
|
||||||
|
|
||||||
|
DB.transaction do
|
||||||
|
site.add_profile_comment(
|
||||||
|
actioning_site_id: current_site.id,
|
||||||
|
message: params[:message]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect "/profile/#{sitename}"
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/tags_mockup' do
|
get '/tags_mockup' do
|
||||||
|
|
9
migrations/022_fix_changes.rb
Normal file
9
migrations/022_fix_changes.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
DB.rename_table :changes, :site_changes
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
DB.drop_column :site_changes, :changes
|
||||||
|
}
|
||||||
|
end
|
19
migrations/023_add_profile_comments.rb
Normal file
19
migrations/023_add_profile_comments.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
DB.rename_column :events, :comment_id, :profile_comment_id
|
||||||
|
|
||||||
|
DB.create_table! :profile_comments do
|
||||||
|
primary_key :id
|
||||||
|
Integer :site_id
|
||||||
|
Integer :actioning_site_id
|
||||||
|
Text :message
|
||||||
|
DateTime :created_at
|
||||||
|
DateTime :updated_at
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
DB.rename_column :events, :profile_comment_id, :comment_id
|
||||||
|
DB.drop_table :profile_comments
|
||||||
|
}
|
||||||
|
end
|
|
@ -1,3 +0,0 @@
|
||||||
class Change < Sequel::Model
|
|
||||||
many_to_one :site
|
|
||||||
end
|
|
|
@ -1,9 +1,9 @@
|
||||||
class Event < Sequel::Model
|
class Event < Sequel::Model
|
||||||
many_to_one :site
|
many_to_one :site
|
||||||
many_to_one :follow
|
one_to_one :follow
|
||||||
many_to_one :tip
|
one_to_one :tip
|
||||||
many_to_one :tag
|
one_to_one :tag
|
||||||
many_to_one :changes
|
one_to_one :site_change
|
||||||
|
many_to_one :profile_comment
|
||||||
one_to_many :likes
|
one_to_many :likes
|
||||||
one_to_many :comments
|
|
||||||
end
|
end
|
9
models/profile_comment.rb
Normal file
9
models/profile_comment.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class ProfileComment < Sequel::Model
|
||||||
|
one_to_one :event
|
||||||
|
many_to_one :site
|
||||||
|
many_to_one :actioning_site, :class => :Site
|
||||||
|
|
||||||
|
def after_create
|
||||||
|
self.event = Event.create site_id: site.id
|
||||||
|
end
|
||||||
|
end
|
|
@ -52,6 +52,7 @@ class Site < Sequel::Model
|
||||||
LOSSLESS_IMAGE_REGEX = /png|bmp|gif/
|
LOSSLESS_IMAGE_REGEX = /png|bmp|gif/
|
||||||
LOSSY_IMAGE_REGEX = /jpg|jpeg/
|
LOSSY_IMAGE_REGEX = /jpg|jpeg/
|
||||||
HTML_REGEX = /htm|html/
|
HTML_REGEX = /htm|html/
|
||||||
|
MAX_COMMENT_SIZE = 420 # Used to be the limit for Facebook.. no comment (PUN NOT INTENDED).
|
||||||
|
|
||||||
SCREENSHOT_RESOLUTIONS = ['235x141', '105x63', '270x162', '37x37', '146x88', '302x182', '90x63', '82x62']
|
SCREENSHOT_RESOLUTIONS = ['235x141', '105x63', '270x162', '37x37', '146x88', '302x182', '90x63', '82x62']
|
||||||
THUMBNAIL_RESOLUTIONS = ['105x63']
|
THUMBNAIL_RESOLUTIONS = ['105x63']
|
||||||
|
@ -60,6 +61,9 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
many_to_many :tags
|
many_to_many :tags
|
||||||
|
|
||||||
|
one_to_many :profile_comments
|
||||||
|
one_to_many :profile_commentings, key: :actioning_site_id, class: :ProfileComment
|
||||||
|
|
||||||
one_to_many :follows
|
one_to_many :follows
|
||||||
one_to_many :followings, key: :actioning_site_id, class: :Follow
|
one_to_many :followings, key: :actioning_site_id, class: :Follow
|
||||||
|
|
||||||
|
@ -73,7 +77,7 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
one_to_many :events
|
one_to_many :events
|
||||||
|
|
||||||
one_to_many :changes
|
one_to_many :site_changes
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def valid_login?(username, plaintext)
|
def valid_login?(username, plaintext)
|
||||||
|
|
4
models/site_change.rb
Normal file
4
models/site_change.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class SiteChange < Sequel::Model
|
||||||
|
many_to_one :site
|
||||||
|
one_to_one :event
|
||||||
|
end
|
|
@ -1,3 +1,11 @@
|
||||||
|
<% events.each do |event| %>
|
||||||
|
<% if event.profile_comment_id %>
|
||||||
|
<%== erb :'_news_profile_comment', layout: false, locals: {event: event} %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class="news-item follow">
|
<div class="news-item follow">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
|
@ -91,4 +99,5 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="actions"><a href="">Like (1)</a> <a href="">Reply</a></div>
|
<div class="actions"><a href="">Like (1)</a> <a href="">Reply</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
8
views/_news_profile_comment.erb
Normal file
8
views/_news_profile_comment.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<div class="news-item comment for-me">
|
||||||
|
<div class="title">
|
||||||
|
<div class="icon" style="background-image:url(https://neocities.org/site_screenshots/codeventurer.jpg);"></div>
|
||||||
|
<a href="" class="user">Foo</a>
|
||||||
|
<span class="date"><%= event.profile_comment.created_at.ago %></span>
|
||||||
|
<div class="comment"><%= event.profile_comment.message %></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -29,18 +29,20 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="content misc-page columns right-col"><div class="col-left">
|
<div class="content misc-page columns right-col"><div class="col-left">
|
||||||
<div class="col col-66">
|
<div class="col col-66">
|
||||||
|
|
||||||
<div class="post-comment">
|
<div class="post-comment">
|
||||||
<input class="" type="text" placeholder="Post on Derp's profile...">
|
<form method="POST" action="/profile/<%= site.username %>/comment">
|
||||||
<a href="" class="btn-Action">Post</a>
|
<input name="csrf_token" type="hidden" value="<%= csrf_token %>">
|
||||||
|
<input name="message" type="text" placeholder="Post a message..." maxlength="<%= Site::MAX_COMMENT_SIZE %>">
|
||||||
|
<button class="btn-Action">Post</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if site.latest_events.empty? %>
|
<% if site.latest_events.empty? %>
|
||||||
<div>
|
<div>
|
||||||
<p>No activity yet.</p>
|
<p>No activity yet.</p>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= erb :'_profile_news', layout: false, locals: {events: events} %>
|
<%== erb :'_news', layout: false, locals: {site: site, events: site.events} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue