Initial check-in; some gruntwork.

This commit is contained in:
Elf M. Sternberg 2012-07-09 13:16:06 -07:00
commit 73c49d2318
15 changed files with 11761 additions and 0 deletions

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
*.pyc
*.pyo
*#
.#*
.DS_Store
*~
npm-debug.log
node_modules/*
dist/*
src/*.html
src/*.js
src/*.css

View File

@ -0,0 +1 @@
What is this I dont even

29
PriorityIgnore.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "PriorityIgnore",
"title": "Priorityignore",
"description": "A simple program to show/hide priorities.",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Elf M. Sternberg",
"email": "elf.sternberg@gmail.com",
"url": "http://elfsternberg.com"
},
"repository": {
"type": "git",
"url": "ssh://jenkins@wish/home/jenkins/repos/priority.git"
},
"bugs": {
"url": ""
},
"licenses": [
{
"type": "CC-Attribution-NonCommercial-ShareAlike",
"url": "/blob/master/LICENSE-CC-Attribution-NonCommercial-ShareAlike"
}
],
"dependencies": {
"jquery": ">= 1.6"
},
"keywords": []
}

64
README.md Normal file
View File

@ -0,0 +1,64 @@
# Priorityignore
A simple program to show/hide priorities.
## Getting Started
Download the [production version][min] or the [development version][max].
[min]: https://raw.github.com//PriorityIgnore/master/dist/PriorityIgnore.min.js
[max]: https://raw.github.com//PriorityIgnore/master/dist/PriorityIgnore.js
In your web page:
```html
<script src="jquery.js"></script>
<script src="dist/PriorityIgnore.min.js"></script>
<script>
jQuery(function($) {
$.awesome(); // "awesome"
});
</script>
```
## Documentation
_(Coming soon)_
## Examples
_(Coming soon)_
## Release History
_(Nothing yet)_
## License
Copyright (c) 2012 Elf M. Sternberg
Licensed under the CC-Attribution-NonCommercial-ShareAlike license.
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).
### Important notes
Please don't edit files in the `dist` subdirectory as they are generated via grunt. You'll find source code in the `src` subdirectory!
While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
### Installing grunt
_This assumes you have [node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed already._
1. Test that grunt is installed globally by running `grunt --version` at the command-line.
1. If grunt isn't installed globally, run `npm install -g grunt` to install the latest version. _You may need to run `sudo npm install -g grunt`._
1. From the root directory of this project, run `npm install` to install the project's dependencies.
### Installing PhantomJS
In order for the qunit task to work properly, [PhantomJS](http://www.phantomjs.org/) must be installed and in the system PATH (if you can run "phantomjs" at the command line, this task should work).
Unfortunately, PhantomJS cannot be installed automatically via npm or grunt, so you need to install it yourself. There are a number of ways to install PhantomJS.
* [PhantomJS and Mac OS X](http://ariya.ofilabs.com/2012/02/phantomjs-and-mac-os-x.html)
* [PhantomJS Installation](http://code.google.com/p/phantomjs/wiki/Installation) (PhantomJS wiki)
Note that the `phantomjs` executable needs to be in the system `PATH` for grunt to see it.
* [How to set the path and environment variables in Windows](http://www.computerhope.com/issues/ch000549.htm)
* [Where does $PATH get set in OS X 10.6 Snow Leopard?](http://superuser.com/questions/69130/where-does-path-get-set-in-os-x-10-6-snow-leopard)
* [How do I change the PATH variable in Linux](https://www.google.com/search?q=How+do+I+change+the+PATH+variable+in+Linux)

4
bin/activate Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
PROJECT_ROOT=`pwd`
PATH="$PROJECT_ROOT/bin:$PROJECT_ROOT/node_modules/.bin:$PATH"
export PATH

129
grunt.js Normal file
View File

@ -0,0 +1,129 @@
/* mode:javascript; tab-width:2; indent-tabs-mode:nil; */
/*global module:false*/
path = require('path');
_und = require('underscore');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:PriorityIgnore.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>', '<file_strip_banner:src/<%= pkg.name %>.js>'],
dest: 'dist/<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
qunit: {
files: ['test/**/*.html']
},
lint: {
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
server: {
port: 8081,
base: './dist/'
},
haml: {
src: ['src/**/*.haml'],
dest: './src/'
},
templatize: {
src: ['src/**/*.html'],
dest: './src'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'lint qunit concat min');
grunt.registerHelper('haml', function(src, dest, done) {
var args = {
cmd: 'haml',
args: ["--unix-newlines", "--no-escape-attrs", "--double-quote-attributes", src]
}
grunt.utils.spawn(args, function(err, result) {
var out = path.basename(src, '.haml');
grunt.file.write(path.join(dest, out + '.html'), result.stdout)
done()
});
});
grunt.registerTask('haml', 'Compile HAML', function() {
var done = this.async(),
sources = grunt.file.expandFiles(grunt.config([this.name, 'src'])),
dest = grunt.config([this.name, 'dest']);
sources.forEach(function(path) {
grunt.helper('haml', path, dest, done);
});
});
grunt.registerHelper('templatize', function(src, dest, done) {
var file = grunt.file.read(src);
console.log('define(' + _und.template(file).source + ');');
done();
});
grunt.registerTask('templatize', 'Compile Underscored HTML to Javascript', function() {
var done = this.async(),
sources = grunt.file.expandFiles(grunt.config([this.name, 'src'])),
dest = grunt.config([this.name, 'dest']);
sources.forEach(function(path) {
grunt.helper('templatize', path, dest, done);
});
});
// grunt.registerTask('haml', function() {
// outputPath = grunt.config('haml.dest');
// files = grunt.file.expandFiles(grunt.config('haml.src')).forEach(function(file) {
// grunt.utils.spawn({
// cmd: 'haml',
// args: ["--unix-newlines", "--no-escape-attrs", "--double-quote-attributes", file]
// }, function(err, result) {
// console.log("FOO", result);
// });
// });
// });
};

14
libs/jquery-loader.js vendored Normal file
View File

@ -0,0 +1,14 @@
(function() {
// Get any jquery=___ param from the query string.
var jqversion = location.search.match(/[?&]jquery=(.*?)(?=&|$)/);
var path;
if (jqversion) {
// A version was specified, load that version from code.jquery.com.
path = 'http://code.jquery.com/jquery-' + jqversion[1] + '.js';
} else {
// No version was specified, load the local version.
path = '../libs/jquery/jquery.js';
}
// This is the only time I'll ever use document.write, I promise!
document.write('<script src="' + path + '"></script>');
}());

9404
libs/jquery/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

232
libs/qunit/qunit.css Normal file
View File

@ -0,0 +1,232 @@
/**
* QUnit v1.4.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
* Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-header label {
display: inline-block;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests ol {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
background-color: #fff;
border-left: 26px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

1659
libs/qunit/qunit.js Normal file

File diff suppressed because it is too large Load Diff

14
package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "Priority-Ignore",
"version": "0.1.0",
"engines": {
"node": ">= 0.6.0"
},
"scripts": {
"test": "grunt qunit"
},
"devDependencies": {
"grunt": "~0.3.11",
"node-static": "~0.6.0"
}
}

44
src/PriorityIgnore.coffee Normal file
View File

@ -0,0 +1,44 @@
require ['jquery', 'priority_tmpl'], ($, priority_template, new_priority_template, help_template, ) ->
class Prioritize
constructor(@repo) ->
@repo.get 'priorities', (p) =>
@priorities = if p? and p.priorities? then p.priorities else []
@render()
$('body').on 'click', @render
$('#thumbsup').on 'click', () => @newPriority('priority')
$('#thumbsdn').on 'click', () => @newPriority('ignore')
save: ->
@repo.save {key: 'priorities', 'priorities': @priorities}, =>
@render()
render: =>
priority_enumerate = (cat) ->
(c for c in @priorities if c.cat == cat)
priority_render = (cat) ->
$('#priority_list').html(priority_template({priorities: priority_enumerate('priority')}))
$('#ignore_list').html(priority_template({priorities: priority_enumerate('ignore')}))
$ ->
prioritize = new Lawnchair {name: 'Prioritize'}, ->
p = this
p.save [
key: 'priorities',
priorities: [
{cat: 'priority', name: 'Omaha, Stormy, Raeney'}
{cat: 'ignore', name: 'Politics'}
{cat: 'priority', name: 'Spiral Genetics'}
{cat: 'priority', name: 'Looking for Work'}
{cat: 'priority', name: 'Writing'}
{cat: 'priority', name: 'Productivity Core'}
{cat: 'priority', name: 'Story Core'}
{cat: 'ignore', name: 'Smut'}
{cat: 'ignore', name: 'Religious Arguments'}
{cat: 'ignore', name: 'PASWO'}
{cat: 'ignore', name: 'Twitter'}
], ->
handler = new Prioritize(p)

67
src/index.haml Normal file
View File

@ -0,0 +1,67 @@
!!! 5
%html{:xmlns => "http://www.w3.org/1999/xhtml"}
%head
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
%meta{:name => "keywords", :content => ""}/
%meta{:name => "description", :content => ""}/
%link{:rel => "stylesheet", :href => "style.css", :type => "text/css"}/
%link{:rel => "shortcut icon", :type => "image/x-icon", :href => "images/favicon.ico"}/
%link{:rel => "shortcut icon", :type => "image/png", :href => "images/favicon.png"}/
%script{:language => "javascript", :type => "text/javascript", :src => "prioritize.js", "data-main" => "prioritize"}
%title Priority / Ignore
%body
#content
#leftbrain
%h1#prioritize Today I Will Pay Attention To:
#priorities
#rightbrain
%h1#prioritize Today I Will Ignore:
#ignorities
#braindiv
#img
#msg
Right now, it&rsquo;s <span id="thetime"></span>.
%p Is <strong>this</strong></p>
%p what you want</p>
%p to be <strong class="doing">doing</strong>
%p right now?
.clearoncolumn
#rightnow
#newcat
%h1 Wouldn't you <strong>rather</strong> be:
<button class="fadebutton" id="addcat" style="display: none">+ New Category</button>
.div(style="clear:both")
#todos
#message(style="display:none")
%h2 How to Use
%p
<b>Priority / Ignore</b> is a simple project reminder. It is
not a to-do list or project manager. It's just a
<i>reminder</i>. After <a
href="https://github.com/elfsternberg/rightnow">downloading
and installing <b>Priority / Ignore!</b> locally</a>, set the
index.html file as your home page, open a new tab and click on
either header.
%p
The idea is simple: every time you open your browser or click
"New Tab," you'll get the <b>Priority / Ignore</b> page.
Every day we should remind ourselves not only of what must be
done, but what we must put aside as trivial and distracting.
%p
All the data is stored locally using the browser's own local
storage mechanism. There is no server, and no data is ever
sent anywhere. Everything on your screen is yours, kept as
secure as you keep your physical hardware.
%p
This message will disappear as soon as you've created your
first entry. You can also <button id="preclose">Close it
now.</button>

31
test/PriorityIgnore.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Priorityignore Test Suite</title>
<!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
<script src="../libs/jquery-loader.js"></script>
<!-- Load local QUnit (grunt requires v1.0.0 or newer). -->
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
<script src="../libs/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
<script src="../src/PriorityIgnore.js"></script>
<script src="PriorityIgnore_test.js"></script>
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
you REALLY want to mess around with jQuery in the console. REMEMBER WE
ARE TESTING YOUR PLUGIN HERE -->
<script>window._$ = jQuery.noConflict(true);</script>
</head>
<body>
<h1 id="qunit-header">Priorityignore Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<span>lame test markup</span>
<span>normal test markup</span>
<span>awesome test markup</span>
</div>
</body>
</html>

View File

@ -0,0 +1,57 @@
/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false*/
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
(function($) {
/*
======== A Handy Little QUnit Reference ========
http://docs.jquery.com/QUnit
Test methods:
expect(numAssertions)
stop(increment)
start(decrement)
Test assertions:
ok(value, [message])
equal(actual, expected, [message])
notEqual(actual, expected, [message])
deepEqual(actual, expected, [message])
notDeepEqual(actual, expected, [message])
strictEqual(actual, expected, [message])
notStrictEqual(actual, expected, [message])
raises(block, [expected], [message])
*/
module('jQuery#awesome', {
setup: function() {
this.elems = $('#qunit-fixture').children();
}
});
test('is chainable', 1, function() {
// Not a bad test to run on collection methods.
strictEqual(this.elems.awesome(), this.elems, 'should be chaninable');
});
test('is awesome', 1, function() {
strictEqual(this.elems.awesome().text(), 'awesomeawesomeawesome', 'should be thoroughly awesome');
});
module('jQuery.awesome');
test('is awesome', 1, function() {
strictEqual($.awesome(), 'awesome', 'should be thoroughly awesome');
});
module(':awesome selector', {
setup: function() {
this.elems = $('#qunit-fixture').children();
}
});
test('is awesome', 1, function() {
// Use deepEqual & .get() when comparing jQuery objects.
deepEqual(this.elems.filter(':awesome').get(), this.elems.last().get(), 'knows awesome when it sees it');
});
}(jQuery));