GithubHelp home page GithubHelp logo

bjdeng / middleman-appcache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryan-scott-dev/middleman-appcache

0.0 1.0 0.0 6 KB

Middleman extension to genereate a Application Cache Manifest to support offline access.

Ruby 100.00%

middleman-appcache's Introduction

Middleman Application Cache

Generate a Application Cache Manifest to support offline access.

Disclaimer

I have developed this for the intention of using it exclusively for single page applications.

While it can be extended to support App Cache Manifests for multiple pages, I have no intent at this point in time to develop support for this.

If it is something that you do need, please let me know and I'll investigate how it could work without compromising the configuration syntax.

Usage

Add the following line to Gemfile, then run bundle install:

gem 'middleman-appcache'

Add a link to the appcache name in you html layout:

<html manifest="manifest.appcache">
  ...
</html>

And active the extension inside config.rb:

activate :app_cache do |config|
  config.cache_manifest = 'manifest.appcache'
  config.cache = %w(index.html favicon.ico stylesheets/*.css javascripts/*.js images/*)
end

Then when you run middleman build, the application cache will be generated in the build directory.

Configuration

The extension has 5 optionally configurable fields:

activate :app_cache do |config|
  config.cache_manifest = 'manifest.appcache'
  config.cache = %w(index.html offline.html favicon.ico stylesheets/*.css javascripts/*.js images/*)
  config.network = %w(/ /login /logout)
  config.fallback = {
    '/' => 'offline.html'
  }
  config.use_relative = false
  config.version_hash = true
end

The above configuration will generate the following appcache:

CACHE MANIFEST

# version 1aadc03fe3f695a96d64f1a190b6253e

CACHE:
/index.html
/offline.html
/favicon.ico
/stylesheets/all-3676b7b2.css
/stylesheets/normalize-6197e73d.css
/javascripts/all-24162989.js
/javascripts/vendor-e28aee79.js
/images/welcome-64a62e79.png

NETWORK:
/
/login
/logout

FALLBACK:
/ /offline.html

cachemanifest

The filename for the generate cache manifest.

Default: 'manifest.appcache'

cache

The list of files, directories, or glob patterns which should be cached.

Default: ['index.html']

network

The list of resources that require the user to be online.

Default: ['*']

fallback

The mapping of fallback resources if a resource is unavailable.

Default: Empty

use_relative

If the resources should be treated as relative from the appcache.

Default: true

version_hash

If a version hash should be generated from the contents of the referenced files.

Default: true

License

Middleman Application Cache was created by Ryan Scott is distributed under the MIT license.

middleman-appcache's People

Contributors

ajanuary avatar ryan-scott-dev avatar

Watchers

 avatar

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.