Coder Social home page Coder Social logo

adsf's People

Contributors

boutil avatar cdchapman avatar da2x avatar denisdefreyne avatar dependabot[bot] avatar edbrannin avatar hipe avatar pcantrell avatar porras avatar vipulnsward avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

adsf's Issues

Basic authentication - out of scope?

How out of scope would it be to consider adding basic auth support?

Ideally - I would love adsf to automatically detect if there is an ADSF_AUTH environment variable, and act accordingly, so we can run:

$ ADSF_AUTH=admin:p4ssw0rd adsf

Since this is Rack, I am guessing it should not be too difficult to add, like:

if ENV['ADSF_AUTH']
  user, pass = ENV['ADSF_AUTH'].split ':'
  
  use Rack::Auth::Basic, "Protected Area" do |username, password|
    username == user && password == pass
  end
end

Content-Type response header missing charset=utf-8

ads returns a Content-Type response header, but its missing the charset=utf-8 component. HTML documents with a <meta charset="utf-8"> declaration works anyway, but other text resources like text/plain doesn’t have a reliable fallback mechanism like this (the BOM character causes more problems than it solves). text/css has @charset="utf-8"; but when did you last see that in use?

Can we stop using flash via rack live-reload ?

The adsf-live gem relies on Rack::LiveReload, which by default still loads swfobject.js as a fall back for browsers that do not support web sockets. This is unlikely to be of use to anyone anymore in 2022, Flash has been deprecated long ago.

While it would be better if the rack -livereload gem changed it's behaviour I don't think they will; the repo sees very few updates and does not accept issue reports. However, we could simply fix it from here by adding the parameter no_swf: true on the call to Rack::LiveReload (in lib/adsf/server.rb:66)

adsf-live does not work with rack 3

Adsf version 1.4.7 started using lower case headers to support rack 3, however the rack-livereload gem that adsf-live depends on has not yet been updated and expects upper case headers. I realise this is something that needs to be updated in the rack-livereload gem, but that project seems dormant.

Until that gem gets updated, I created this monkey patch that seems to work:

module Rack
  class LiveReload

    class ProcessingSkipAnalyzer
      def html?;@headers['content-type'] =~ %r{text/html}; end
    end

    def call(env)
      result = dup._call(env)
      if (headers=result[1]).is_a?(Hash) && headers['Content-Length']
        headers['content-length']=headers.delete('Content-Length')
        headers.transform_keys!{_1.downcase}
      end
      result
    end

  end
end

It's a bit tricky to get the patch to load at the right time when used with nanoc, I ended up creating a custom nanoc command.

Invoke LiveReload with random port

Hey,

Have you thought of initializing Rack::LiveReload with any unused port rather than its default? Having all instances use the same port prevents running two [Nanoc] sites with nanoc live in parallel.

Support for optional .html extension

When uploading a static site to most static site hosts, they allow accessing any HTML page, without the HTML extension - so for example, server.com/software will load the software.html file if it is found.

It would be very helpful if such a behavior is either enabled by default in adsf, or can be added with a command line flag.

Based on this SO answer I have prepared the following config.ru file as a proof of concept:

# config.ru - run with rackup
require 'adsf'

class OptionalHtml
  def initialize(app)
    @app = app
  end

  def call(env)
    orig_path = env['PATH_INFO']
    resp = @app.call(env.merge!({'PATH_INFO' => "#{orig_path}.html"}))
    found = resp[0] == 404 ? false : resp
    found or @app.call(env.merge!('PATH_INFO' => orig_path))
  end
end

use OptionalHtml
use Adsf::Rack::IndexFileFinder, root: '.'
run Rack::File.new '.'

Would it make sense to add such a behavior to adsf?

Publish current version to rubygems.org

When I installed your gem from rubygems.org and tried to run it, it crashed:

/Users/angelika/.rvm/gems/ruby-2.3.0/gems/adsf-1.2.0/bin/adsf:64:in `<top (required)>': uninitialized constant Rack::Handler::Mongrel (NameError)
    from /Users/angelika/.rvm/gems/ruby-2.3.0/bin/adsf:23:in `load'
    from /Users/angelika/.rvm/gems/ruby-2.3.0/bin/adsf:23:in `<main>'
    from /Users/angelika/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/angelika/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

I had to clone the repo and build the gem myself, it's working now. I know it's not a big deal, but maybe you could publish the current version (without Mongrel dependency) to rubygems.org, so it's more convenient for people to install it.

Custom Headers?

Hey. Thanks for your great job. I just wondered if it was possible to add a custom header ?

To prevent such exceptions like

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Thanks

adsf-live sends the path of the changed file instead of the path of the web page

Steps to reproduce

  1. Use nanoc with adsf-live
  2. Make a change to a page

Expected behavior

adsf-live should send the path of the web page to live reload.

Actual behavior

adsf-live sends the path to the file here
path: "#{Dir.pwd}#{path}"

instead of path: path

Details

You typically only want to reload the page if the change occurred on the page you are viewing. When you change a layout in nanoc it will send many changed pages over the web socket. For livereload to know if the current page changed it needs to compare document.location.pathname with path. At this time it always reloads even if no match is found, but that results in ugly flickering if many pages change. It's not hard to modify the livereload.js to only reload if the path matches, but this comparison is needlessly complicated because the file path is being sent, from which the path first needs to be extracted.

Deprecation warning for Rack::File

Steps to reproduce

  1. use adsf

Expected behavior

No warnings

Actual behavior

It shows /Users/jmfaber/.rvm/gems/ruby-3.1.2/gems/rack-3.0.7/lib/rack/file.rb:5: warning: Rack::File is deprecated and will be removed in Rack 3.1

Details

Rack::File has been renamed to Rack::Files apparently. Because adsf can no longer run on rack 2 (because it depends on the rackup gem that require rack 3), it should be safe to simply rename it here:

run ::Rack::File.new(root)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.