Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

init

  • Loading branch information...
commit 38fac1cf1e4d37f533333525a45b72e695533eea 0 parents
@benhartley authored
2  .gitignore
@@ -0,0 +1,2 @@
+node_modules
+demo/
4 .npmignore
@@ -0,0 +1,4 @@
+.git*
+Cakefile
+src
+demo/
24 Cakefile
@@ -0,0 +1,24 @@
+fs = require 'fs'
+{exec} = require 'child_process'
+
+ansi =
+ red : '\x1B[31m'
+ green : '\x1B[36m'
+ yellow : '\x1B[33m'
+ blue : '\x1B[34m'
+ dark_grey : '\x1B[1;30m'
+ light_grey : '\x1B[1;32m'
+ reset : '\x1B[0m'
+
+log = (message, color) ->
+ console.log ansi[color] + message + ansi.reset
+
+option '-m', '--message [COMMIT_MESSAGE]', 'set git commit message'
+
+task 'build', 'build from src files', (options) ->
+ invoke 'build:coffee'
+
+task 'build:coffee', 'build /lib from /src', (options) ->
+ exec 'coffee -c -o lib src', (err, stdout, stderr) ->
+ err && throw err
+ log 'Build Coffee OK!', 'green'
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Ben Hartley
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
23 README.md
@@ -0,0 +1,23 @@
+# Google Drive CMS
+Fed-up with clients sending copy in Excel spreadsheets, hand-written on the back of an envelope, or by carrier-pigeon? Try this.
+
+```
+npm install googcms
+```
+
+## Minimum-viable CMS?
+Let a Google spreadsheet take care of auth, versioning, storage, and pretty much everything else. All you need to worry about is having `googlecl` installed on your server (see note below), and adding a `.googcms.yml` file to your project with the following fields:
+
+``` yaml .googcms.yml
+document : DocName # Exactly as appears on Google Drive
+column_key : 0 # Column on spreadsheet for string identifiers (numbered from 0)
+column_value : 1 # Column with actual string in
+```
+
+## Example spreadsheet
+<iframe width='500' height='300' frameborder='0' src='https://docs.google.com/spreadsheet/pub?key=0AgBCP8hZC0GXdE5TQlM0d0N2YURPM3RSMWQ2djNRZnc&output=html&widget=true'></iframe>
+
+## Installing googlecl
+`googlecl` is a great little tool for accessing Google services from the command-line. However, the project seemed mothballed until recently. The packaged version dates from 2011 and is broken... but, the latest version from the svn trunk has fixed a bunch of bugs, including (most importantly for us) the ability to download spreadsheets from Google Drive (née Google Docs).
+
+
7 bin/googcms
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
+
+require(lib + '/googcms').run();
5 googcms.sh
@@ -0,0 +1,5 @@
+mkdir -p /user/local/googlecl; pushd $_
+svn checkout http://googlecl.googlecode.com/svn/trunk/ .
+sudo python setup.py install --record=files.txt
+google docs list
+popd
42 lib/googcms.js
@@ -0,0 +1,42 @@
+// Generated by CoffeeScript 1.3.1
+(function() {
+ var csv, exec, fs, yaml;
+
+ yaml = require('js-yaml');
+
+ fs = require('fs');
+
+ csv = require('csv');
+
+ exec = require('child_process').exec;
+
+ exports.run = function() {
+ var config, obj;
+ config = yaml.load(fs.readFileSync('.googcms.yml'));
+ obj = {};
+ return exec('google docs get ' + config.document + ' strings.csv', function(err, stdout, stderr) {
+ err && (function() {
+ throw err;
+ })();
+ console.log(stdout);
+ return csv().from('strings.csv').on('record', function(d, i) {
+ if (!(i === 0 || d[0] === '')) {
+ return obj[d[config.column_key]] = d[config.column_value];
+ }
+ }).on('end', function() {
+ return fs.writeFile('strings.json', JSON.stringify(obj), function(err) {
+ err && (function() {
+ throw err;
+ })();
+ console.log('JSON saved');
+ return fs.unlink('strings.csv', function(err) {
+ return err && (function() {
+ throw err;
+ })();
+ });
+ });
+ });
+ });
+ };
+
+}).call(this);
27 package.json
@@ -0,0 +1,27 @@
+{
+ "name": "googcms",
+ "description": "Google Drive CMS",
+ "keywords": ["cms", "google docs"],
+ "author": "Ben Hartley",
+ "version": "0.0.1",
+ "licenses": [{
+ "type": "MIT",
+ "url": "https://raw.github.com/benhartley/googcms/master/LICENSE"
+ }],
+ "directories": {
+ "lib": "./lib/googcms"
+ },
+ "main": "./lib/googcms",
+ "bin": {
+ "googcms": "./bin/googcms"
+ },
+ "bugs": "http://github.com/benhartley/googcms/issues",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/benhartley/googcms.git"
+ },
+ "dependencies": {
+ "js-yaml" : "*",
+ "csv" : "*"
+ }
+}
21 src/googcms.coffee
@@ -0,0 +1,21 @@
+yaml = require 'js-yaml'
+fs = require 'fs'
+csv = require 'csv'
+{exec} = require 'child_process'
+
+exports.run = ->
+ config = yaml.load fs.readFileSync '.googcms.yml'
+ obj = {}
+ exec 'google docs get ' + config.document + ' strings.csv', (err, stdout, stderr) ->
+ err && throw err
+ console.log stdout
+ csv().from('strings.csv')
+ .on 'record', (d, i) ->
+ unless i is 0 or d[0] is ''
+ obj[d[config.column_key]] = d[config.column_value]
+ .on 'end', ->
+ fs.writeFile 'strings.json', JSON.stringify(obj), (err) ->
+ err && throw err
+ console.log 'JSON saved'
+ fs.unlink 'strings.csv', (err) ->
+ err && throw err
Please sign in to comment.
Something went wrong with that request. Please try again.