mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
a start on dynamic featured front sites
This commit is contained in:
parent
44350c9d84
commit
4a150f2564
4 changed files with 40 additions and 31 deletions
17
app/admin.rb
17
app/admin.rb
|
@ -61,6 +61,21 @@ post '/admin/mark_nsfw' do
|
|||
redirect '/admin'
|
||||
end
|
||||
|
||||
post '/admin/feature' do
|
||||
require_admin
|
||||
site = Site[username: params[:username]]
|
||||
|
||||
if site.nil?
|
||||
flash[:error] = 'User not found'
|
||||
redirect '/admin'
|
||||
end
|
||||
|
||||
site.featured_at = Time.now
|
||||
site.save_changes(validate: false)
|
||||
flash[:success] = 'Site has been featured.'
|
||||
redirect '/admin'
|
||||
end
|
||||
|
||||
def require_admin
|
||||
redirect '/' unless signed_in? && current_site.is_admin
|
||||
end
|
||||
end
|
||||
|
|
|
@ -211,6 +211,10 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
class << self
|
||||
def featured(limit=5)
|
||||
select(:id, :username, :title, :domain).exclude(featured_at: nil).order(:featured_at.desc).limit(limit)
|
||||
end
|
||||
|
||||
def valid_email_unsubscribe_token?(email, token)
|
||||
email_unsubscribe_token(email) == token
|
||||
end
|
||||
|
|
|
@ -62,4 +62,17 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col col-50">
|
||||
<h2>Feature Site</h2>
|
||||
<form id="featureSite" action="/admin/feature" method="POST">
|
||||
<%== csrf_token_input_html %>
|
||||
<p>This site will be featured on the front page and in a special browse section.</p>
|
||||
<p>Site Name:</p>
|
||||
<p><input type="text" name="username" placeholder="edwardsnowden" autocapitalize="off" autocorrect="off"></p>
|
||||
<p><input class="btn-Action" type="submit" value="Feature Site"></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -210,36 +210,13 @@
|
|||
<div class="nav prev"></div>
|
||||
-->
|
||||
<ul class="website-Gallery hp-Gallery">
|
||||
<li>
|
||||
<a href="http://dragonquest.neocities.org/" title="The Quest of Dragons" target="_blank">
|
||||
<img src="//neocities.org/site_screenshots/dragonquest/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of The Quest of Dragons" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://codeventurer.neocities.org/" title="codeventurer" target="_blank">
|
||||
<img src="http://neocities.org/site_screenshots/codeventurer/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of codeventurer" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://clouds.neocities.org/" title="Cloud Quotes" target="_blank">
|
||||
<img src="//neocities.org/site_screenshots/clouds/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of Cloud Quotes" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://manatee.neocities.org/" title="Title of Website" target="_blank">
|
||||
<img src="//neocities.org/site_screenshots/manatee/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of TITLE OF WEBSITE" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://suppilulemur.neocities.org/" title="Sokoban" target="_blank">
|
||||
<img src="//neocities.org/site_screenshots/suppilulemur/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of Sokoban" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://drawinglair.neocities.org/" title="Tomasz Zawadzki" target="_blank">
|
||||
<img src="//neocities.org/site_screenshots/drawinglair/index.html.210x158.jpg" class="neo-SS" alt="Thumbnail of Tomasz Zawadzki" />
|
||||
</a>
|
||||
</li>
|
||||
<% Site.featured.each do |site| %>
|
||||
<li>
|
||||
<a href="<%= site.uri %>" title="<%= site.title %>" target="_blank">
|
||||
<img src="<%= site.screenshot_url 'index.html', '210x158' %>" class="neo-SS" alt="<%= site.title %>" />
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<!--
|
||||
<div class="nav next"></div>
|
||||
|
|
Loading…
Add table
Reference in a new issue