Giter Site home page Giter Site logo

middleman-spreadsheet's Introduction

middleman-spreadsheet

Gem Version

Middleman extension for using Google spreadsheet as data files. Edit

Installation

Add this line to your application's Gemfile:

gem 'middleman-spreadsheet'

And then execute:

$ bundle

Setup

  1. Go to Google API Console and creates your own API credentials.
    • Enable Drive API
  2. Create google credentials json like
{
 "client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
 "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
  1. Activate :spreadsheet like below.
activate :spreadsheet do |spreadsheet|
  spreadsheet.config = "google_credentials.json"
  spreadsheet.spreadsheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxx/edit#gid=0"
end

If you want to manage credentials without json, you could to use spreadsheet.credentials option.

See gimite/google-drive-ruby documentation for more detail authorization information.

Usage

Create spreadsheet

Create spreadsheet.

Specify spreadsheet

You can specify spreadsheet by spreadsheet_url

spreadsheet.spreadsheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxx/edit#gid=0"

or spreadsheet_key

spreadsheet.spreadsheet_key = "xxxxxxxxxxxxxxxxxxxxx"

or spreadsheet_title.

spreadsheet.spreadsheet_title = "foo bar sheet"

Use in template

You can use data.spreadsheet.<worksheet_title> like below.

%ul
  - data.spreadsheet.Sheet1.each do |item|
    %li #{item.id} #{item.foo} #{item.foo}

Use in config.rb

You can use app.data.spreadsheet.<worksheet_title> like below.

app.data.spreadsheet.Sheet1.each do |row|
  proxy "/foo/#{row.id}.html", "/items/show.html", locals: { foo: row }
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hogelog/middlmean-spreadsheet.

License

The gem is available as open source under the terms of the MIT License.

middleman-spreadsheet's People

Contributors

hogelog avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.