mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
more encoding fixes
This commit is contained in:
parent
1463074f35
commit
44644cc7fa
2 changed files with 9 additions and 6 deletions
|
@ -147,7 +147,8 @@ get '/browse/search' do
|
||||||
@total_results = @resp['searchInformation']['totalResults'].to_i
|
@total_results = @resp['searchInformation']['totalResults'].to_i
|
||||||
@resp['items'].each do |item|
|
@resp['items'].each do |item|
|
||||||
link = Addressable::URI.parse(item['link'])
|
link = Addressable::URI.parse(item['link'])
|
||||||
item['readable_link'] = link.host+Rack::Utils.unescape(Rack::Utils.unescape(link.path)) # Yes, it needs to be decoded twice
|
unencoded_path = Rack::Utils.unescape(Rack::Utils.unescape(link.path)) # Yes, it needs to be decoded twice
|
||||||
|
item['unencoded_link'] = link.host+unencoded_path
|
||||||
item['link'] = link
|
item['link'] = link
|
||||||
|
|
||||||
next if link.host == 'neocities.org'
|
next if link.host == 'neocities.org'
|
||||||
|
@ -156,16 +157,18 @@ get '/browse/search' do
|
||||||
site = Site[username: username]
|
site = Site[username: username]
|
||||||
next if site.nil? || site.is_deleted || site.is_nsfw
|
next if site.nil? || site.is_deleted || site.is_nsfw
|
||||||
|
|
||||||
link.path << 'index' if link.path[-1] == '/'
|
screenshot_path = unencoded_path
|
||||||
|
|
||||||
|
screenshot_path << 'index' if screenshot_path[-1] == '/'
|
||||||
|
|
||||||
['.html', '.htm'].each do |ext|
|
['.html', '.htm'].each do |ext|
|
||||||
if site.screenshot_exists?(link.path + ext, '540x405')
|
if site.screenshot_exists?(screenshot_path + ext, '540x405')
|
||||||
link.path += ext
|
screenshot_path += ext
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
item['screenshot_url'] = site.screenshot_url(link.path, '540x405')
|
item['screenshot_url'] = site.screenshot_url(screenshot_path, '540x405')
|
||||||
@items << item
|
@items << item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="result-url">
|
<div class="result-url">
|
||||||
<a href="<%= item['link'] %>"><%= item['readable_link'] %></a>
|
<a href="<%= item['link'] %>"><%= item['unencoded_link'] %></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="result-snippet">
|
<p class="result-snippet">
|
||||||
|
|
Loading…
Add table
Reference in a new issue