Skip to content

Commit

Permalink
Merge branch 'origin/firefox'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndragomirov committed May 30, 2014
2 parents 71c815c + 23d5887 commit dc40476
Show file tree
Hide file tree
Showing 119 changed files with 17,666 additions and 2,702 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.idea/*
*.zip
.hgignore
.gitignore
.git/*
.hg/*
tmp/*
build/*
node_modules/*
fontello/*
twitch_now.zip
/fontello-39648cf2/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "chrome-platform-analytics"]
path = chrome-platform-analytics
url = [email protected]:GoogleChrome/chrome-platform-analytics.git
149 changes: 111 additions & 38 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,75 @@ var fs = require('fs'),

module.exports = function (grunt){

grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-version');

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

watch : {
scripts: {
files : ['lib/*'],
tasks : ['default'],
clean : {
chrome : {
src: ["./build/chrome/*"]
},
firefox: {
src: ["./build/firefox/*"]
}
},
watch : {
firefox: {
files : ['templates/**', 'common/**', "firefox/**", "chrome/**"],
tasks : ['firefox', 'chrome'],
options: {
nospawn: true
}
}
},
version : {
version : {
options : {
pkg : "version.json",
prefix: '[\'"]version[\'"]?\\s*[:=]\\s*[\'"]'
},
manifests: {
src: ['manifests/opera.json', 'manifests/chrome.json']
src: ['chrome/manifest.json', 'firefox/package.json']
}
},
copy : {
chrome: {
expand : true,
src : 'manifests/chrome.json',
dest : './',
flatten: true,
rename : function (dest, src){
return dest + "manifest.json";
}
// concat : {
// options: {
// separator: ';\n\n'
// },
// src : chromePopup,
// dest: "build/chrome/common/lib/concat.js"
// }
// },
copy : {
firefox: {
files: [
{
expand: true,
src : ["./common/**"],
dest : './build/firefox/data'
},
{
expand: true,
src : ["./firefox/**"],
cwd : "./",
dest : './build/'
}
]
},
opera : {
chrome : {
files: [
{
expand: true,
src : ["./common/**", "./_locales/**"],
dest : './build/chrome'
},
{
expand: true,
src : ["./chrome/**"],
cwd : "./",
dest : './build/'
},
]},
opera : {
expand : true,
src : 'manifests/opera.json',
dest : './',
Expand All @@ -50,7 +82,7 @@ module.exports = function (grunt){
}
}
},
handlebars: {
handlebars : {
compile: {
options: {
namespace : "Handlebars.templates",
Expand All @@ -61,25 +93,56 @@ module.exports = function (grunt){
},

files: {
"dist/templates.js": "lib/templates/*.html"
"common/dist/templates.js": "templates/*"
}
}
},
compress : {
chrome: {
options: {
archive: 'dist/twitch-now-chrome.zip'
},
files : [
{src: ['**'], cwd: "build/chrome/", expand: true }
]
}
},
'mozilla-addon-sdk': {
'1_16': {
options: {
revision: '1.16'
}
}
},
'mozilla-cfx' : {
'run_stable': {
options: {
"mozilla-addon-sdk": "1_16",
extension_dir : "build/firefox",
command : "run"
}
}
},
'mozilla-cfx-xpi' : {
stable: {
options: {
'mozilla-addon-sdk': '1_16',
extension_dir : 'build/firefox',
dist_dir : 'dist/',
arguments : '--output-file=twitch-now-firefox.xpi'
}
}
}

});


grunt.registerTask('zip', '', function (){
var done = this.async();
var zip = exec(' zip -r twitch_now.zip ./chrome-platform-analytics/google-analytics-bundle.js ./_locales/* ./audio/* ./lib/* ./oauth2/* ./icons/* ./css/* ./dist/* ./manifest.json ./html/* ', function (error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if ( error !== null ) {
grunt.log.error('This is an error message.\n' + error);
return false;
}
done();
});
grunt.registerTask('i18n', function (){
var localesObj = {};
var locales = fs.readdirSync("_locales");
for ( var i = 0; i < locales.length; i++ ) {
var file = fs.readFileSync(__dirname + "/_locales/" + locales[i] + "/messages.json");
localesObj[locales[i]] = JSON.parse(file);
}
fs.writeFileSync("common/dist/locales.json", JSON.stringify(localesObj, null, 2), "utf8");
});

grunt.registerTask('bump', function (){
Expand All @@ -98,9 +161,19 @@ module.exports = function (grunt){
done();
});

grunt.loadNpmTasks('grunt-mozilla-addon-sdk');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-version');


grunt.registerTask('default', 'copy:chrome handlebars'.split(' '));
grunt.registerTask('default', 'chrome'.split(' '));
grunt.registerTask('opera', 'bump version copy:opera handlebars'.split(' '));
grunt.registerTask('chrome', 'bump version copy:chrome handlebars'.split(' '));
grunt.registerTask('prod', 'zip'.split(' '));
grunt.registerTask('firefox', 'clean:firefox i18n handlebars copy:firefox'.split(' '));
grunt.registerTask('chrome', 'clean:chrome handlebars copy:chrome'.split(' '));
grunt.registerTask('dist', 'bump version chrome compress:chrome mozilla-addon-sdk mozilla-cfx-xpi'.split(' '));
};
35 changes: 35 additions & 0 deletions chrome/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var providerOpts = {
api : "https://api.twitch.tv/kraken/oauth2/authorize",
response_type: 'code',
client_id : 'b4sj5euottb8mm7pc1lfvi84kvzxqxk',
client_secret: '2m42qpmxfy5l2ik4c93s0qco4vzfgr0',
api_scope : 'user_follows_edit user_read',
redirect_uri : 'http://ndragomirov.github.io/twitch.html'
};

var twitchOauth = OAuth2.addAdapter({
id : 'twitch',
codeflow: {
method: "POST",
url : "https://api.twitch.tv/kraken/oauth2/token"
},
opts : providerOpts
});

chrome.runtime.onMessage.addListener(function (msg){
if ( msg.id == "OAUTH2_AUTH" ) {
twitchOauth.authorize(function (){})
}
})

chrome.runtime.onMessage.addListener(function (msg){
if ( msg.id == "OAUTH2_TOKEN_GET" ) {
chrome.runtime.sendMessage({id: "OAUTH2_TOKEN", value: twitchOauth.getAccessToken()});
}
})

chrome.runtime.onMessage.addListener(function (msg){
if ( msg.id == "OAUTH2_REVOKE" ) {
twitchOauth.clearAccessToken();
}
})
13 changes: 13 additions & 0 deletions chrome/common/html/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="../../lib/3rd/jquery.js"></script>
<script type="text/javascript" src="../../lib/3rd/underscore.js"></script>
<script type="text/javascript" src="../../lib/3rd/backbone.js"></script>
<script type="text/javascript" src="../oauth2/oauth2.js"></script>
<script type="text/javascript" src="../oauth2/adapters/twitch.js"></script>
<script type="text/javascript" src="../../lib/twitch-api.js"></script>
<script type="text/javascript" src="../../lib/app.js"></script>
</head>
</html>
22 changes: 22 additions & 0 deletions chrome/common/html/notification.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="../../css/reset.css">
<link rel="stylesheet" href="../../css/notification.css">
</head>
<body>
<img class="logo" src="../../css/img/footer_glitch_dark.png">

<div id="output">
<div class="streams"></div>
<div class="more"></div>
</div>
<script type="text/javascript" src="../../lib/3rd/jquery.js"></script>
<script type="text/javascript" src="../../lib/3rd/handlebars.js"></script>
<script type="text/javascript" src="../../lib/3rd/underscore.js"></script>
<script type="text/javascript" src="../../lib/3rd/backbone.js"></script>
<script type="text/javascript" src="../../lib/3rd/i18n.js"></script>
<script type="text/javascript" src="../../../common/dist/templates.js"></script>
<script type="text/javascript" src="../../lib/notification.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions chrome/common/lib/popup-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function (){
var scripts = [
"common/lib/utils.js",
"common/lib/3rd/jquery.js",
"common/lib/3rd/baron.js",
"common/lib/3rd/bootstrap.js",
"common/lib/3rd/underscore.js",
"common/lib/3rd/backbone.js",
"common/lib/3rd/handlebars.js",
"common/lib/3rd/prettydate.js",
"common/lib/3rd/i18n.js",
"common/dist/templates.js",
"common/lib/handlebars-helpers.js",
"common/lib/popup.js",
"common/lib/routes.js",
"common/lib/init.js",
];

scripts = scripts.map(function (v){
return "<script src='" + chrome.runtime.getURL(v) + "'></script>";
}).join('');

document.write(scripts);
})();

35 changes: 35 additions & 0 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name" : "Twitch Now",
"version" : "1.1.78",
"default_locale" : "en",
"manifest_version" : 2,
"description" : "Explore games & track your favorite streams on Twitch",
"background" : {
"scripts": [
"common/lib/3rd/jquery.js",
"common/lib/3rd/underscore.js",
"common/lib/3rd/backbone.js",
"common/lib/utils.js",
"common/lib/oauth2.js",
"background.js",
"common/lib/twitch-api.js",
"common/lib/app.js"
]
},
"minimum_chrome_version" : "29",
"content_security_policy" : "script-src 'self' https://connect.facebook.net https://ssl.google-analytics.com https://platform.twitter.com; object-src 'self'",
"icons" : {
"16" : "common/icons/32_1.png",
"48" : "common/icons/48_1.png",
"128": "common/icons/128_1.png"
},
"web_accessible_resources": ["common/*", "css/*", "dist/*", "oauth2/*", "lib/*"],
"browser_action" : {
"default_icon" : {
"19": "common/icons/19_2.png",
"38": "common/icons/38_2.png"
},
"default_popup": "common/html/popup.html"
},
"permissions" : ["storage", "background", "https://*/*", "http://*/*", "notifications", "tabs"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions common/css/baron.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.scroller {
height: 100%;
overflow-y: scroll;
/* -webkit-overflow-scrolling: touch; *//* uncomment to accelerate scrolling on iOS */
}

.scroller::-webkit-scrollbar {
/* Preventing webkit cross-direction scrolling bug */
width: 0;
}

.baron .scroller__bar {
display: block;
}

.scroller__bar {
position: absolute;
z-index: 1;
right: 0;
width: 10px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.6);
display: none;
}

.scroller__bar:active {
background: rgba(255, 255, 255, 1);
}

Loading

0 comments on commit dc40476

Please sign in to comment.