fix js file, remove old surf mode crap

This commit is contained in:
Kyle Drake 2015-03-28 22:57:31 -07:00
parent 2e76bc9a0b
commit eb316031a2
4 changed files with 8 additions and 85 deletions

View file

@ -15,74 +15,3 @@ get '/surf/:username' do |username|
not_found if @site.nil?
erb :'surf', layout: false
end
def surf_proxy
username = request.host.match /^(\w+)/i
resp = RestClient.get "http://#{username}.neocities.org#{request.path}"
content_type resp.headers[:content_type]
if content_type.match(/^text\/html/)
body = resp.body+erb(:'surf/_surf_iframe_injection', layout: false)
else
body = resp.body
end
halt body
end
def surf_proxy_uri(username)
$surf_proxy_uri ||= Addressable::URI.parse $config['surf_proxy_uri']
new_uri = $surf_proxy_uri.dup
new_uri.host = "#{username}.#{new_uri.host}"
new_uri.to_s
end
=begin
get %r{\/surf\/proxy\/([\w-]+)\/(.+)|\/surf\/proxy\/([\w-]+)\/?} do
captures = params[:captures].compact
username = captures.first
path = captures.length == 2 ? captures.last : ''
site = Site.where(username: username).select(:id, :username, :title, :domain).first
not_found if site.nil?
resp = RestClient.get "http://#{site.username}.neocities.org/#{path}"
content_type resp.headers[:content_type]
site_body = resp.body
unless path == '/' || path == '' || path.match(/\.html?$/i)
return site_body
end
attributes = ['src', 'href', 'background']
new_site_body = site_body.dup
site_body.gsub(/(?<name>\b\w+\b)\s*=\s*(?<value>"[^"]*"|'[^']*'|[^"'<>\s]+)/i) do |ele|
attributes.each do |attr|
if ele.match /#{attr} ?=/
ele_match = ele.match(/\"(.+)\"|\'(.+)\'/)
next if ele_match.nil? || ele_match.captures.nil?
uri = ele_match.captures.first
new_ele = nil
if uri.match(/^\w+:\/\/|^\/\//i)
if ele.match(/^href/i)
new_ele = ele + ' target="_blank"'
else
new_ele = ele
end
else
new_ele = ele.gsub(uri, "#{$config['surf_proxy_uri']}/surf/proxy/#{site.username}/#{uri}")
end
new_site_body.gsub! ele, new_ele if new_ele
end
end
end
new_site_body
end
=end

View file

@ -11,8 +11,6 @@ development:
ip_hash_salt: "400$8$1$fc21863da5d531c1"
proxy_pass: 'somethinglongandrandom'
email_unsubscribe_token: 'somethingrandom'
surf_proxy_uri: 'http://surf.somedomain.local:9292' # May want to use dnsmasq instead of /etc/hosts here
surf_iframe_source: 'http://127.0.0.1:9292'
logs_path: /path/to/nginx/logs
test:
database: 'postgres://neocities@localhost/neocities_test'
@ -27,5 +25,3 @@ test:
ip_hash_salt: "400$8$1$fc21863da5d531c1"
proxy_pass: 'somethinglongandrandom'
email_unsubscribe_token: 'somethingrandom'
surf_proxy_uri: 'http://surf.somedomain.local:9292'
surf_iframe_source: 'http://127.0.0.1:9292'

View file

@ -1,10 +1,8 @@
<script>
function _nc_surf_page_overload() {
var ele = document.getElementsByTagName('a')
for(var i=0; i<ele.length; i++) {
if(ele[i].href.match(/^\w+:\/\//i) && !ele[i].href.match(/^.+\.neocities\.org/i))
ele[i].setAttribute('target', '_blank')
}
function _nc_surf_page_overload() {
var ele = document.getElementsByTagName('a')
for(var i=0; i<ele.length; i++) {
if(ele[i].href.match(/^\w+:\/\//i) && !ele[i].href.match(/^.+\.neocities\.org/i))
ele[i].setAttribute('target', '_blank')
}
_nc_surf_page_overload()
</script>
}
_nc_surf_page_overload()

View file

@ -236,7 +236,7 @@
</li>
</ul>
</div>
<iframe src="<%= "#{surf_proxy_uri @site.username}" %>" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0" id="website-frame" name="website-frame"></iframe>
<iframe src="<%= @site.uri+"?surf=1" %>" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0" id="website-frame" name="website-frame"></iframe>
<script src="/js/jquery-1.11.0.min.js"></script>
<script src="/js/bootstrap.min.js"></script>