Browse Source

Move the builder page to the main branch.

master
Artem Sapegin 7 years ago
parent
commit
1e3cb062ee
  1. 5
      .gitignore
  2. 2
      dist/social-likes_flat.css
  3. 23
      gh-pages/.jshintrc
  4. 182
      gh-pages/Gruntfile.js
  5. 41
      gh-pages/content/.common.json
  6. 40
      gh-pages/content/en/index.md
  7. 39
      gh-pages/content/ru/index.md
  8. BIN
      gh-pages/img/noise.png
  9. BIN
      gh-pages/img/social-likes.png
  10. 7
      gh-pages/js/libs/doT.min.js
  11. 2
      gh-pages/js/libs/jquery-1.8.2.min.js
  12. 1695
      gh-pages/js/libs/jszip-deflate.js
  13. 735
      gh-pages/js/libs/jszip.js
  14. 2
      gh-pages/js/libs/store+json2.min.js
  15. 258
      gh-pages/js/main.js
  16. 72
      gh-pages/js/mylibs/htmlhl.js
  17. 15
      gh-pages/proxy/proxy.php
  18. 166
      gh-pages/styles/gh-page.styl
  19. 11
      gh-pages/styles/index.styl
  20. 144
      gh-pages/styles/styles.styl
  21. 31
      gh-pages/tamia/modules/checkbox/Readme.md
  22. 1
      gh-pages/tamia/modules/checkbox/check.svg
  23. 43
      gh-pages/tamia/modules/checkbox/example.html
  24. 108
      gh-pages/tamia/modules/checkbox/index.styl
  25. 1
      gh-pages/tamia/modules/checkbox/radio.svg
  26. 18
      gh-pages/tamia/modules/code/Readme.md
  27. 1
      gh-pages/tamia/modules/code/example.html
  28. 44
      gh-pages/tamia/modules/code/index.styl
  29. 67
      gh-pages/tamia/modules/code/tomorrow.styl
  30. 14
      gh-pages/tamia/modules/fade/Readme.md
  31. 1
      gh-pages/tamia/modules/fade/example.html
  32. 11
      gh-pages/tamia/modules/fade/index.styl
  33. 1
      gh-pages/tamia/modules/fade/mask.svg
  34. 9
      gh-pages/tamia/modules/fade/mask_src.svg
  35. 39
      gh-pages/tamia/modules/flippable/Readme.md
  36. 4
      gh-pages/tamia/modules/flippable/example.html
  37. 36
      gh-pages/tamia/modules/flippable/index.styl
  38. 19
      gh-pages/tamia/modules/flippable/script.coffee
  39. 38
      gh-pages/tamia/modules/flippable/script.js
  40. 33
      gh-pages/tamia/modules/form/Readme.md
  41. 13
      gh-pages/tamia/modules/form/example.html
  42. 136
      gh-pages/tamia/modules/form/index.styl
  43. 31
      gh-pages/tamia/modules/form/script.coffee
  44. 35
      gh-pages/tamia/modules/form/script.js
  45. 29
      gh-pages/tamia/modules/list/Readme.md
  46. 6
      gh-pages/tamia/modules/list/example.html
  47. 33
      gh-pages/tamia/modules/list/index.styl
  48. 22
      gh-pages/tamia/modules/media/Readme.md
  49. 4
      gh-pages/tamia/modules/media/example.html
  50. 18
      gh-pages/tamia/modules/media/index.styl
  51. 32
      gh-pages/tamia/modules/password/Readme.md
  52. 4
      gh-pages/tamia/modules/password/example.html
  53. 60
      gh-pages/tamia/modules/password/index.styl
  54. 45
      gh-pages/tamia/modules/password/script.coffee
  55. 64
      gh-pages/tamia/modules/password/script.js
  56. 17
      gh-pages/tamia/modules/print/Readme.md
  57. 103
      gh-pages/tamia/modules/print/index.styl
  58. 31
      gh-pages/tamia/modules/richtypo/Readme.md
  59. 32
      gh-pages/tamia/modules/richtypo/index.styl
  60. 22
      gh-pages/tamia/modules/select/Readme.md
  61. 1
      gh-pages/tamia/modules/select/arrow.svg
  62. 10
      gh-pages/tamia/modules/select/example.html
  63. 86
      gh-pages/tamia/modules/select/index.styl
  64. 28
      gh-pages/tamia/modules/select/script.coffee
  65. 46
      gh-pages/tamia/modules/select/script.js
  66. 45
      gh-pages/tamia/modules/spinner/Readme.md
  67. 1
      gh-pages/tamia/modules/spinner/example.html
  68. 81
      gh-pages/tamia/modules/spinner/index.styl
  69. 53
      gh-pages/tamia/modules/spinner/script.coffee
  70. 71
      gh-pages/tamia/modules/spinner/script.js
  71. BIN
      gh-pages/tamia/modules/spinner/spinner.gif
  72. 20
      gh-pages/tamia/modules/switcher/Readme.md
  73. 8
      gh-pages/tamia/modules/switcher/example.html
  74. 77
      gh-pages/tamia/modules/switcher/index.styl
  75. 12
      gh-pages/tamia/modules/text/Readme.md
  76. 7
      gh-pages/tamia/modules/text/example.html
  77. 68
      gh-pages/tamia/modules/text/index.styl
  78. 15
      gh-pages/tamia/modules/tooltip/Readme.md
  79. 1
      gh-pages/tamia/modules/tooltip/example.html
  80. 63
      gh-pages/tamia/modules/tooltip/index.styl
  81. 138
      gh-pages/tamia/tamia/bootstrap.styl
  82. 20
      gh-pages/tamia/tamia/classes.styl
  83. 215
      gh-pages/tamia/tamia/component.coffee
  84. 278
      gh-pages/tamia/tamia/component.js
  85. 18
      gh-pages/tamia/tamia/functions.styl
  86. 147
      gh-pages/tamia/tamia/images.styl
  87. 39
      gh-pages/tamia/tamia/index.styl
  88. 295
      gh-pages/tamia/tamia/layout.styl
  89. 195
      gh-pages/tamia/tamia/links.styl
  90. 41
      gh-pages/tamia/tamia/mediaqueries.styl
  91. 174
      gh-pages/tamia/tamia/misc.styl
  92. 363
      gh-pages/tamia/tamia/tamia.js
  93. 212
      gh-pages/tamia/vendor/transition-events.js
  94. 17
      gh-pages/templates/build.tmpl.html
  95. 21
      gh-pages/templates/functions.js
  96. 19
      gh-pages/templates/index.tmpl.html
  97. 5
      gh-pages/templates/prepend.tmpl.html
  98. 249
      gh-pages/templates/template.xhtml
  99. 9442
      gh-pages/vendor/modernizr.js
  100. 16
      package.json

5
.gitignore

@ -1 +1,6 @@
node_modules
gh-pages/public/social-likes
gh-pages/public/build
gh-pages/public/src
gh-pages/public/index.html
gh-pages/public/ru/index.html

2
dist/social-likes_flat.css

File diff suppressed because one or more lines are too long

23
gh-pages/.jshintrc

@ -0,0 +1,23 @@
{
"browser": true,
"jquery": true,
"white": false,
"smarttabs": true,
"eqeqeq": true,
"immed": true,
"latedef": false,
"newcap": true,
"undef": true,
"trailing": true,
"esnext": true,
"camelcase": true,
"bitwise": true,
"noempty": true,
"unused": "vars",
"strict": true,
"globals": {
"Modernizr": false,
"tamia": false,
"Component": false
}
}

182
gh-pages/Gruntfile.js

@ -0,0 +1,182 @@
module.exports = function(grunt) {
'use strict';
grunt.file.expand('../node_modules/grunt-*/tasks').forEach(grunt.loadTasks);
var debug = !!grunt.option('debug');
var prefix = debug ? '' : '/social-likes/';
grunt.initConfig({
pkg: grunt.file.readJSON('../package.json'),
banner: '/* Author: Artem Sapegin, http://sapegin.me, <%= grunt.template.today("yyyy") %> */\n',
modernizr: {
main: {
devFile: 'vendor/modernizr.js',
outputFile: 'public/build/modernizr.js',
dest: 'public/build/modernizr.js',
extra: {
load: false
},
files: {
src: ['public/build/scripts.js', 'public/build/styles.css']
}
}
},
jshint: {
all: ['js/main.js']
},
concat: {
main: {
src: [
'js/mylibs/htmlhl.js',
'js/libs/doT.min.js',
'js/libs/jszip.js',
'js/libs/jszip-deflate.js',
'js/libs/store+json2.min.js',
'tamia/vendor/*.js',
'tamia/tamia/tamia.js',
'js/main.js'
],
dest: 'public/build/scripts.js'
}
},
uglify: {
main: {
options: {
banner: '<%= banner %>',
compress: {
global_defs: {
DEBUG: debug
}
}
},
files: {
'<%= concat.main.dest %>': '<%= concat.main.dest %>'
}
}
},
stylus: {
options: {
'include css': true,
urlfunc: 'embedurl',
banner: '<%= banner %>',
define: {
DEBUG: debug
},
paths: ['tamia'],
use: [
function() {
return (require('autoprefixer-stylus'))({browsers: ['last 2 versions', 'ie 8', 'ie 9']});
}, debug || (require('csso-stylus'))
]
},
compile: {
files: {
'public/build/styles.css': 'styles/index.styl'
}
}
},
sweet: {
content_dir: 'content',
publish_dir: 'public',
templates_dir: 'templates',
default_template_id: 'template',
langs: ['ru', 'en'],
root_lang: 'en',
url_prefixes: {
ru: prefix + 'ru/',
en: prefix
},
uri_prefixes: {
ru: prefix + 'ru/',
en: prefix
},
files: {
modernizr: {
path: 'public/build/modernizr.js',
href: prefix + 'build/modernizr.js?{version}'
},
css: {
path: 'public/build/styles.css',
href: prefix + 'build/styles.css?{version}'
},
js: {
path: '<%= concat.main.dest %>',
href: prefix + 'build/scripts.js?{version}'
},
sljs: {
path: 'public/src/social-likes.min.js',
href: prefix + 'src/social-likes.min.js?{version}'
},
slcss_classic: {
path: 'public/src/social-likes_classic.css',
href: prefix + 'src/social-likes_classic.css?{version}'
},
slcss_flat: {
path: 'public/src/social-likes_flat.css',
href: prefix + 'src/social-likes_flat.css?{version}'
},
slcss_birman: {
path: 'public/src/social-likes_birman.css',
href: prefix + 'src/social-likes_birman.css?{version}'
}
}
},
replace: {
version: {
files: {
'public/index.html': 'public/index.html',
'public/ru/index.html': 'public/ru/index.html'
},
options: {
patterns: [
{
match: /(<!\-\-VERSION\-\->).*?(<!\-\-\/VERSION\-\->)/,
replacement: '$1<%= pkg.version %>$2'
}
]
}
}
},
connect: {
server: {
options: {
port: 9000,
base: '.'
}
}
},
watch: {
livereload: {
options: {
livereload: true
},
files: ['<%= concat.main.dest %>', 'public/build/styles.css']
},
concat: {
options: {
atBegin: true
},
files: '<%= concat.main.src %>',
tasks: 'concat'
},
stylus: {
options: {
atBegin: true
},
files: 'styles/**',
tasks: 'stylus'
},
sweet: {
options: {
atBegin: true
},
files: ['content/**', 'templates/**'],
tasks: 'sweet'
}
}
}
);
return grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'stylus', 'modernizr', 'sweet', 'replace']);
};

41
gh-pages/content/.common.json

@ -0,0 +1,41 @@
{
"sites": [
{
"id": "facebook",
"name": "Facebook",
"checked": true
},
{
"id": "twitter",
"name": "Twitter",
"checked": true
},
{
"id": "plusone",
"name": "Google+",
"checked": true
},
{
"id": "mailru",
"name": "Мой мир",
"checked": true,
"langs": ["ru"]
},
{
"id": "vkontakte",
"name": "Вконтакте",
"checked": true,
"langs": ["ru"]
},
{
"id": "odnoklassniki",
"checked": true,
"name": "Одноклассники",
"langs": ["ru"]
},
{
"id": "pinterest",
"name": "Pinterest"
}
]
}

40
gh-pages/content/en/index.md

@ -0,0 +1,40 @@
name: Social Likes
title: Social Likes: beautiful social like buttons with jQuery
description: Single style social like buttons with counters for jQuery: Facebook, Twitter, Google+, Pinterest and also popular <a href="/social-likes/ru/">Russian social networks</a>.
descriptionHead: Single style buttons with like counters: Facebook, Twitter, Google+, Pinterest and also popular Russian social networks.
translationLink: /social-likes/ru/
translationTitle: По-русски
builderSkin: Skin
builderSkinClassic: Classic
builderSkinFlat: Flat β
builderSkinBirman: Birman β
builderType: Look
builderTypeHorizontal: Horizontal
builderTypeVertical: Vertical
builderTypeSingle: Single button
builderCounters: Show counters
builderLight: Light style
builderSites: Websites
builderUrl: URL
builderUrlHelp: When buttons used on different page
builderTitle: Title
builderTitleHelp: When differs from current page’s title
builderTwitterVia: Twitter Via
builderTwitterViaHelp: Username
builderTwitterRelated: Twitter Related
builderTwitterRelatedHelp: Username:Description
builderPinterestMedia: Image URL
builderPinterestMediaHelp: Image URL for Pinterest (required)
titleFacebook: Share link on Facebook
titleTwitter: Share link on Twitter
titlePlusone: Share link on Google+
titlePinterest: Share image on Pinterest
singleTitle: Share
downloadArchive: Download the Buttons
or: or
browseCode: view source
onGitHub: on GitHub
archiveContains: Version <a href="https://github.com/sapegin/social-likes/blob/master/Changelog.md"><!--VERSION--><!--/VERSION--></a>. Archive contains all you need to use like buttons with chosen options.
archiveFooter: <a href="http://sapegin.github.com/social-likes/">Social Likes</a> — <a href="https://github.com/sapegin/social-likes/Readme.md">documentation</a>
docs: <a href="https://github.com/sapegin/social-likes/blob/master/Readme.md">Documentation</a> and advanced customization examples.<br>Report bugs <a href="https://github.com/sapegin/social-likes/issues">on GitHub</a>.
footer: © 2014 <a href="https://github.com/sapegin">Artem Sapegin</a> and contributors. Flat skin: <a href="http://genn.org/">Genn Osypenko</a>, Birman skin: <a href="http://ilyabirman.net/">Ilya Birman</a>

39
gh-pages/content/ru/index.md

@ -0,0 +1,39 @@
name: Social Likes
title: Social Likes — красивые кнопки «лайков» социальных сетей с использованием jQuery
description: Красивые кнопки «лайков» со счётчиками в едином стиле для социальных сетей: Facebook, Twitter, Вконтакте, Одноклассники, Мой мир, Google+ и Pinterest. Кнопки уже используют <a href="http://www.snob.ru/">Сноб</a>, <a href="http://sberbank.ru/">Сбербанк</a>, <a href="http://blogengine.ru/blogs/">блоги на Эгее</a> и&nbsp;многие другие.
translationLink: /social-likes/
translationTitle: In English
builderSkin: Скин
builderSkinClassic: Классический
builderSkinFlat: Плоский β
builderSkinBirman: Бирман β
builderType: Вид
builderTypeHorizontal: Горизонтальный
builderTypeVertical: Вертикальный
builderTypeSingle: Одной кнопкой
builderCounters: Счётчики
builderLight: Лёгкий стиль
builderSites: Сайты
builderUrl: Адрес страницы
builderUrlHelp: Если отличается от адреса страницы, где размещены кнопки
builderTitle: Название
builderTitleHelp: Если отличается от заголовка страницы, где размещены кнопки
builderTwitterVia: Twitter Via
builderTwitterViaHelp: Имя в Твиттере
builderTwitterRelated: Twitter Related
builderTwitterRelatedHelp: Имя:Описание
builderPinterestMedia: URL картинки
builderPinterestMediaHelp: URL картинки для Пинтереста (обязательно)
titleFacebook: Поделиться ссылкой на Фейсбуке
titleTwitter: Поделиться ссылкой в Твиттере
titlePlusone: Поделиться ссылкой в Гугл-плюсе
titlePinterest: Поделиться картинкой на Пинтересте
singleTitle: Поделиться
downloadArchive: Скачать кнопки
or: или
browseCode: посмотреть код
onGitHub: на Гитхабе
archiveContains: Версия <a href="https://github.com/sapegin/social-likes/blob/master/Changelog.md"><!--VERSION--><!--/VERSION--></a>. В архиве есть всё необходимое для подключения кнопок с выбранными параметрами.
archiveFooter: <a href="http://sapegin.github.com/social-likes/">Social Likes</a> — <a href="https://github.com/sapegin/social-likes/Readme.md">документация</a>
docs: <a href="https://github.com/sapegin/social-likes/blob/master/Readme.md">Документация</a>, примеры настройки и расширения.<br>Об ошибках пишите <a href="https://github.com/sapegin/social-likes/issues">на Гитхаб</a>.
footer: © 2014 <a href="https://github.com/sapegin">Артём Сапегин</a> и другие. Плоский скин: <a href="http://genn.org/">Гена Осипенко</a>, скин Бирмана: <a href="http://ilyabirman.ru/">Илья Бирман</a>

BIN
gh-pages/img/noise.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
gh-pages/img/social-likes.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

7
gh-pages/js/libs/doT.min.js

@ -0,0 +1,7 @@
// Laura Doktorova https://github.com/olado/doT
(function(){function o(){var b={"&":"&#38;","<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","/":"&#47;"},a=/&(?!#?\w+;)|<|>|"|'|\//g;return function(f){return f?f.toString().replace(a,function(g){return b[g]||g}):f}}function p(b,a,f){return(typeof a==="string"?a:a.toString()).replace(b.define||h,function(g,e,c,i){if(e.indexOf("def.")===0)e=e.substring(4);if(!(e in f))if(c===":")f[e]=i;else eval("def['"+e+"']="+i);return""}).replace(b.use||h,function(g,e){var c=eval(e);return c?p(b,c,f):c})}function l(b){return b.replace(/\\('|\\)/g,
"$1").replace(/[\r\t\n]/g," ")}var j={version:"0.2.0",templateSettings:{evaluate:/\{\{([\s\S]+?)\}\}/g,interpolate:/\{\{=([\s\S]+?)\}\}/g,encode:/\{\{!([\s\S]+?)\}\}/g,use:/\{\{#([\s\S]+?)\}\}/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,conditional:/\{\{\?(\?)?\s*([\s\S]*?)\s*\}\}/g,iterate:/\{\{~\s*(?:\}\}|([\s\S]+?)\s*\:\s*([\w$]+)\s*(?:\:\s*([\w$]+))?\s*\}\})/g,varname:"it",strip:true,append:true,selfcontained:false},template:undefined,compile:undefined},m=function(){return this||(0,eval)("this")}();
if(typeof module!=="undefined"&&module.exports)module.exports=j;else if(typeof define==="function"&&define.amd)define(function(){return j});else m.doT=j;m.encodeHTML=o();var q={append:{start:"'+(",end:")+'",startencode:"'+encodeHTML("},split:{start:"';out+=(",end:");out+='",startencode:"';out+=encodeHTML("}},h=/$^/;j.template=function(b,a,f){a=a||j.templateSettings;var g=a.append?q.append:q.split,e,c=0,i;if(a.use||a.define){var r=m.def;m.def=f||{};b=p(a,b,m.def);m.def=r}b=("var out='"+(a.strip?b.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g,
" ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,""):b).replace(/'|\\/g,"\\$&").replace(a.interpolate||h,function(n,d){return g.start+l(d)+g.end}).replace(a.encode||h,function(n,d){e=true;return g.startencode+l(d)+g.end}).replace(a.conditional||h,function(n,d,k){return d?k?"';}else if("+l(k)+"){out+='":"';}else{out+='":k?"';if("+l(k)+"){out+='":"';}out+='"}).replace(a.iterate||h,function(n,d,k,s){if(!d)return"';} } out+='";c+=1;i=s||"i"+c;d=l(d);return"';var arr"+c+"="+d+";if(arr"+c+"){var "+k+","+i+"=-1,l"+
c+"=arr"+c+".length-1;while("+i+"<l"+c+"){"+k+"=arr"+c+"["+i+"+=1];out+='"}).replace(a.evaluate||h,function(n,d){return"';"+l(d)+"out+='"})+"';return out;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|}|^|{)out\+='';/g,"$1").replace(/\+''/g,"").replace(/(\s|;|}|^|{)out\+=''\+/g,"$1out+=");if(e&&a.selfcontained)b="var encodeHTML=("+o.toString()+"());"+b;try{return new Function(a.varname,b)}catch(t){typeof console!=="undefined"&&console.log("Could not create a template function: "+
b);throw t;}};j.compile=function(b,a){return j.template(b,null,a)}})();

2
gh-pages/js/libs/jquery-1.8.2.min.js

File diff suppressed because one or more lines are too long

1695
gh-pages/js/libs/jszip-deflate.js

File diff suppressed because it is too large

735
gh-pages/js/libs/jszip.js

@ -0,0 +1,735 @@
/**
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2012 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See LICENSE.markdown.
Usage:
zip = new JSZip();
zip.file("hello.txt", "Hello, World!").add("tempfile", "nothing");
zip.folder("images").file("smile.gif", base64Data, {base64: true});
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
zip.remove("tempfile");
base64zip = zip.generate();
**/
/**
* Representation a of zip file in js
* @constructor
* @param {String=} data the data to load, if any (optional).
* @param {Object=} options the options for creating this objects (optional).
*/
var JSZip = function(data, options) {
// object containing the files :
// {
// "folder/" : {...},
// "folder/data.txt" : {...}
// }
this.files = {};
// Where we are in the hierarchy
this.root = "";
if(data) {
this.load(data, options);
}
};
JSZip.signature = {
LOCAL_FILE_HEADER : "\x50\x4b\x03\x04",
CENTRAL_FILE_HEADER : "\x50\x4b\x01\x02",
CENTRAL_DIRECTORY_END : "\x50\x4b\x05\x06",
ZIP64_CENTRAL_DIRECTORY_LOCATOR : "\x50\x4b\x06\x07",
ZIP64_CENTRAL_DIRECTORY_END : "\x50\x4b\x06\x06",
DATA_DESCRIPTOR : "\x50\x4b\x07\x08"
};
// Default properties for a new file
JSZip.defaults = {
base64: false,
binary: false,
dir: false,
date: null
};
JSZip.prototype = (function ()
{
/**
* A simple object representing a file in the zip file.
* @constructor
* @param {string} name the name of the file
* @param {string} data the data
* @param {Object} options the options of the file
*/
var ZipObject = function (name, data, options) {
this.name = name;
this.data = data;
this.options = options;
};
ZipObject.prototype = {
/**
* Return the content as UTF8 string.
* @return {string} the UTF8 string.
*/
asText : function ()
{
return this.options.binary ? JSZip.prototype.utf8decode(this.data) : this.data;
},
/**
* Returns the binary content.
* @return {string} the content as binary.
*/
asBinary : function ()
{
return this.options.binary ? this.data : JSZip.prototype.utf8encode(this.data);
}
};
/**
* Transform an integer into a string in hexadecimal.
* @private
* @param {number} dec the number to convert.
* @param {number} bytes the number of bytes to generate.
* @returns {string} the result.
*/
var decToHex = function(dec, bytes) {
var hex = "", i;
for(i = 0; i < bytes; i++)
{
hex += String.fromCharCode(dec&0xff);
dec=dec>>>8;
}
return hex;
};
/**
* Merge the objects passed as parameters into a new one.
* @private
* @param {...Object} var_args All objects to merge.
* @return {Object} a new object with the data of the others.
*/
var extend = function () {
var result = {}, i, attr;
for (i = 0; i < arguments.length; i++) // arguments is not enumerable in some browsers
{
for (attr in arguments[i])
{
if(typeof result[attr] === "undefined")
{
result[attr] = arguments[i][attr];
}
}
}
return result;
};
/**
* Transforms the (incomplete) options from the user into the complete
* set of options to create a file.
* @private
* @param {Object} o the options from the user.
* @return {Object} the complete set of options.
*/
var prepareFileAttrs = function (o) {
o = o || {};
if (o.base64 === true && o.binary == null) {
o.binary = true;
}
o = extend(o, JSZip.defaults);
o.date = o.date || new Date();
return o;
};
/**
* Add a file in the current folder.
* @private
* @param {string} name the name of the file
* @param {string} data the data of the file
* @param {Object} o the options of the file
* @return {Object} the new file.
*/
var fileAdd = function (name, data, o) {
// be sure sub folders exist
var parent = parentFolder(name);
if (parent) {
folderAdd.call(this, parent);
}
o = prepareFileAttrs(o);
return this.files[name] = {name: name, data: data, options:o};
};
/**
* Find the parent folder of the path.
* @private
* @param {string} path the path to use
* @return {string} the parent folder, or ""
*/
var parentFolder = function (path) {
if (path.slice(-1) == '/')
{
path = path.substring(0, path.length - 1);
}
var lastSlash = path.lastIndexOf('/');
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
};
/**
* Add a (sub) folder in the current folder.
* @private
* @param {string} name the folder's name
* @return {Object} the new folder.
*/
var folderAdd = function (name) {
// Check the name ends with a /
if (name.slice(-1) != "/") {
name += "/"; // IE doesn't like substr(-1)
}
// Does this folder already exist?
if (!this.files[name])
{
// be sure sub folders exist
var parent = parentFolder(name);
if (parent) {
folderAdd.call(this, parent);
}
fileAdd.call(this, name, '', {dir:true});
}
return this.files[name];
};
/**
* Generate the data found in the local header of a zip file.
* Do not create it now, as some parts are re-used later.
* @private
* @param {Object} file the file to use.
* @param {string} utfEncodedFileName the file name, utf8 encoded.
* @param {string} compressionType the compression to use.
* @return {Object} an object containing header and compressedData.
*/
var prepareLocalHeaderData = function(file, utfEncodedFileName, compressionType) {
var useUTF8 = utfEncodedFileName !== file.name,
data = file.data,
o = file.options,
dosTime,
dosDate;
// date
// @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
// @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
// @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
dosTime = o.date.getHours();
dosTime = dosTime << 6;
dosTime = dosTime | o.date.getMinutes();
dosTime = dosTime << 5;
dosTime = dosTime | o.date.getSeconds() / 2;
dosDate = o.date.getFullYear() - 1980;
dosDate = dosDate << 4;
dosDate = dosDate | (o.date.getMonth() + 1);
dosDate = dosDate << 5;
dosDate = dosDate | o.date.getDate();
if (o.base64 === true) {
data = JSZipBase64.decode(data);
}
// decode UTF-8 strings if we are dealing with text data
if(o.binary === false) {
data = this.utf8encode(data);
}
var compression = JSZip.compressions[compressionType];
var compressedData = compression.compress(data);
var header = "";
// version needed to extract
header += "\x0A\x00";
// general purpose bit flag
// set bit 11 if utf8
header += useUTF8 ? "\x00\x08" : "\x00\x00";
// compression method
header += compression.magic;
// last mod file time
header += decToHex(dosTime, 2);
// last mod file date
header += decToHex(dosDate, 2);
// crc-32
header += decToHex(this.crc32(data), 4);
// compressed size
header += decToHex(compressedData.length, 4);
// uncompressed size
header += decToHex(data.length, 4);
// file name length
header += decToHex(utfEncodedFileName.length, 2);
// extra field length
header += "\x00\x00";
return {
header:header,
compressedData:compressedData
};
};
// return the actual prototype of JSZip
return {
/**
* Read an existing zip and merge the data in the current JSZip object.
* The implementation is in jszip-load.js, don't forget to include it.
* @param {string} stream The stream to load
* @param {Object} options Options for loading the stream.
* options.base64 : is the stream in base64 ? default : false
* @return {JSZip} the current JSZip object
*/
load : function (stream, options)
{
throw new Error("Load method is not defined. Is the file jszip-load.js included ?");
},
/**
* Filter nested files/folders with the specified function.
* @param {Function} search the predicate to use :
* function (relativePath, file) {...}
* It takes 2 arguments : the relative path and the file.
* @return {Array} An array of matching elements.
*/
filter : function (search)
{
var result = [], filename, relativePath, file, fileClone;
for (filename in this.files)
{
file = this.files[filename];
// return a new object, don't let the user mess with our internal objects :)
fileClone = new ZipObject(file.name, file.data, extend(file.options));
relativePath = filename.slice(this.root.length, filename.length);
if (filename.slice(0, this.root.length) === this.root && // the file is in the current root
search(relativePath, fileClone)) // and the file matches the function
{
result.push(fileClone);
}
}
return result;
},
/**
* Add a file to the zip file, or search a file.
* @param {string|RegExp} name The name of the file to add (if data is defined),
* the name of the file to find (if no data) or a regex to match files.
* @param {string} data The file data, either raw or base64 encoded
* @param {Object} o File options
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
* a file (when searching by string) or an array of files (when searching by regex).
*/
file : function(name, data, o)
{
if (arguments.length === 1)
{
if (name instanceof RegExp)
{
var regexp = name;
return this.filter(function(relativePath, file) {
return !file.options.dir && regexp.test(relativePath);
});
}
else // text
{
return this.filter(function (relativePath, file) {
return !file.options.dir && relativePath === name;
})[0]||null;
}
}
else // more than one argument : we have data !
{
name = this.root+name;
fileAdd.call(this, name, data, o);
}
return this;
},
/**
* Add a directory to the zip file, or search.
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
*/
folder : function(arg)
{
if (!arg)
{
throw new Error("folder : wrong argument");
}
if (arg instanceof RegExp)
{
return this.filter(function(relativePath, file) {
return file.options.dir && arg.test(relativePath);
});
}
// else, name is a new folder
var name = this.root + arg;
var newFolder = folderAdd.call(this, name);
// Allow chaining by returning a new object with this folder as the root
var ret = this.clone();
ret.root = newFolder.name;
return ret;
},
/**
* Delete a file, or a directory and all sub-files, from the zip
* @param {string} name the name of the file to delete
* @return {JSZip} this JSZip object
*/
remove : function(name)
{
name = this.root + name;
var file = this.files[name];
if (!file)
{
// Look for any folders
if (name.slice(-1) != "/") {
name += "/";
}
file = this.files[name];
}
if (file)
{
if (!file.options.dir)
{
// file
delete this.files[name];
}
else
{
// folder
var kids = this.filter(function (relativePath, file) {
return file.name.slice(0, name.length) === name;
});
for (var i = 0; i < kids.length; i++)
{
delete this.files[kids[i].name];
}
}
}
return this;
},
/**
* Generate the complete zip file
* @param {Object} options the options to generate the zip file :
* - base64, true to generate base64.
* - compression, "STORE" by default.
* @return {string} the zip file
*/
generate : function(options)
{
options = extend(options || {}, {
base64 : true,
compression : "STORE"
});
var compression = options.compression.toUpperCase();
// The central directory, and files data
var directory = [], files = [], fileOffset = 0;
if (!JSZip.compressions[compression]) {
throw compression + " is not a valid compression method !";
}
for (var name in this.files)
{
if( !this.files.hasOwnProperty(name) ) { continue; }
var file = this.files[name];
var utfEncodedFileName = this.utf8encode(file.name);
var fileRecord = "",
dirRecord = "",
data = prepareLocalHeaderData.call(this, file, utfEncodedFileName, compression);
fileRecord = JSZip.signature.LOCAL_FILE_HEADER + data.header + utfEncodedFileName + data.compressedData;
dirRecord = JSZip.signature.CENTRAL_FILE_HEADER +
// version made by (00: DOS)
"\x14\x00" +
// file header (common to file and central directory)
data.header +
// file comment length
"\x00\x00" +
// disk number start
"\x00\x00" +
// internal file attributes TODO
"\x00\x00" +
// external file attributes
(this.files[name].dir===true?"\x10\x00\x00\x00":"\x00\x00\x00\x00")+
// relative offset of local header
decToHex(fileOffset, 4) +
// file name
utfEncodedFileName;
fileOffset += fileRecord.length;
files.push(fileRecord);
directory.push(dirRecord);
}
var fileData = files.join("");
var dirData = directory.join("");
var dirEnd = "";
// end of central dir signature
dirEnd = JSZip.signature.CENTRAL_DIRECTORY_END +
// number of this disk
"\x00\x00" +
// number of the disk with the start of the central directory
"\x00\x00" +
// total number of entries in the central directory on this disk
decToHex(files.length, 2) +
// total number of entries in the central directory
decToHex(files.length, 2) +
// size of the central directory 4 bytes
decToHex(dirData.length, 4) +
// offset of start of central directory with respect to the starting disk number
decToHex(fileData.length, 4) +
// .ZIP file comment length
"\x00\x00";
var zip = fileData + dirData + dirEnd;
return (options.base64) ? JSZipBase64.encode(zip) : zip;
},
/**
*
* Javascript crc32
* http://www.webtoolkit.info/
*
*/
crc32 : function(str, crc)
{
if (str === "" || typeof str === "undefined") {
return 0;
}
var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
if (typeof(crc) == "undefined") { crc = 0; }
var x = 0;
var y = 0;
crc = crc ^ (-1);
for( var i = 0, iTop = str.length; i < iTop; i++ ) {
y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
x = "0x" + table.substr( y * 9, 8 );
crc = ( crc >>> 8 ) ^ x;
}
return crc ^ (-1);
},
// Inspired by http://my.opera.com/GreyWyvern/blog/show.dml/1725165
clone : function()
{
var newObj = new JSZip();
for (var i in this)
{
if (typeof this[i] !== "function")
{
newObj[i] = this[i];
}
}
return newObj;
},
/**
* http://www.webtoolkit.info/javascript-utf8.html
*/
utf8encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
/**
* http://www.webtoolkit.info/javascript-utf8.html
*/
utf8decode : function (utftext) {
var string = "";
var i = 0;
var c = 0, c1 = 0, c2 = 0, c3 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};
}());
/*
* Compression methods
* This object is filled in as follow :
* name : {
* magic // the 2 bytes indentifying the compression method
* compress // function, take the uncompressed content and return it compressed.
* uncompress // function, take the compressed content and return it uncompressed.
* }
*
* STORE is the default compression method, so it's included in this file.
* Other methods should go to separated files : the user wants modularity.
*/
JSZip.compressions = {
"STORE" : {
magic : "\x00\x00",
compress : function (content)
{
return content; // no compression
},
uncompress : function (content)
{
return content; // no compression
}
}
};
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
* Hacked so that it doesn't utf8 en/decode everything
**/
var JSZipBase64 = (function() {
// private property
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
return {
// public method for encoding
encode : function(input, utf8) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
_keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
_keyStr.charAt(enc3) + _keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function(input, utf8) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = _keyStr.indexOf(input.charAt(i++));
enc2 = _keyStr.indexOf(input.charAt(i++));
enc3 = _keyStr.indexOf(input.charAt(i++));
enc4 = _keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
return output;
}
};
}());
// enforcing Stuk's coding style
// vim: set shiftwidth=3 softtabstop=3:

2
gh-pages/js/libs/store+json2.min.js

File diff suppressed because one or more lines are too long

258
gh-pages/js/main.js

@ -0,0 +1,258 @@
/* Author: Artem Sapegin, http://sapegin.me, 2012 */
/*global tamia:false, doT:true, htmlhl:false, JSZip:false, store:false */
;(function ($) {
'use strict';
$.extend(doT.templateSettings, {
strip: false,
varname: '$'
});
var lang = $('html').attr('lang'),
skins = ['flat', 'classic', 'birman'],
skin = 'classic',
downloadData = {
lang: lang,
jquery_ver: jQuery.fn.jquery,
footer: $('#index_footer_tmpl').html(),
html: '',
skin: skin
},
prefix = location.hostname === '127.0.0.1' ? '' : '/social-likes/',
sourceFiles = {
'social-likes.min.js': {url: prefix + 'src/social-likes.min.js'},
'social-likes_{skin}.css': {url: prefix + 'src/social-likes_{skin}.css'}
},
templateIndex = doT.template($('#index_tmpl').html().replace(/\\\//g, '/')),
experimental = location.hash === '#ponies',
// simple = !('download' in document.createElement('a'));
simple = true; // Because of bug in Chrome 35: https://code.google.com/p/chromium/issues/detail?id=377860
// stackoverflow.com/questions/1184624/convert-form-data-to-js-object-with-jquery
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
// jasonwyatt.tumblr.com/post/10481498815/how-to-correctly-debounce-a-javascript-function
function debounce(fn, debounceDuration){
// summary:
// Returns a debounced function that will make sure the given
// function is not triggered too much.
// fn: Function
// Function to debounce.
// debounceDuration: Number
// OPTIONAL. The amount of time in milliseconds for which we
// will debounce the function. (defaults to 100ms)
debounceDuration = debounceDuration || 100;
return function(){
if (!fn.debouncing) {
fn.debouncing = true;
}
clearTimeout(fn.debounceTimeout);
var args = Array.prototype.slice.apply(arguments);
fn.debounceTimeout = setTimeout(function() {
fn.lastReturnVal = fn.apply(window, args);
fn.debouncing = false;
}, debounceDuration);
return fn.lastReturnVal;
};
}
function escapeValue(value) {
return value
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
;
}
function escapeFormData(data) {
var fields = ['url', 'title', 'twitter_via', 'twitter_related', 'pinterest_media'];
for (var fieldIdx = 0; fieldIdx < fields.length; fieldIdx++) {
var field = fields[fieldIdx];
data[field] = escapeValue(data[field]);
}
return data;
}
function fillForm(form, data) {
jQuery.each(data, function(name, value) {
var field = form.find('[name="' + name + '"]'),
type = field.attr('type');
switch (type) {
case 'checkbox':
field.prop('checked', !!value);
break;
case 'radio':
field.filter('[value="' + value + '"]').prop('checked', true);
break;
default:
field.val(value);
break;
}
});
}
function cleanHtml(code) {
return code
.replace(/\n[\n\t]*\n/g, '\n') // Remove empty lines
.replace(/ {2,}/g, ' ') // Remove extra spaces
;
}
function highlight(code) {
return htmlhl(code.replace(/\\\//g, '/'));
}
function download(e) {
var files = getFiles();
var zip = new JSZip();
zip.file('index.html', templateIndex(downloadData));
for (var fileName in files) {
zip.file(fileName, files[fileName]);
}
var content = zip.generate();
if (simple) {
var form = $('#download-proxy'),
field = form.find('[name="content"]');
field.val(content);
form.submit();
return false;
}
else {
$(e.target).attr('href', 'data:application/zip;base64,' + content);
}
}
function getFiles() {
var files = {};
for (var fileName in sourceFiles) {
files[getFilenameForSkin(fileName)] = getFile(fileName);
}
return files;
}
function getFile(fileName) {
var file = sourceFiles[fileName];
var url = getFilenameForSkin(file.url);
if (!file.files) file.files = {};
if (!file.files[url]) {
$.ajax(url, { async: false, dataType: 'html' }).then(function(data) {
file.files[url] = data;
});
}
return file.files[url];
}
function getFilenameForSkin(fileName) {
return fileName.replace('{skin}', skin);
}
tamia.initComponents({
builder: function(elem) {
var form = $(elem),
preview = $('.js-preview'),
code = $('.js-code'),
twitterExtra = form.find('.js-twitter-extra'),
pinterestExtra = form.find('.js-pinterest-extra'),
lightStyle = form.find('.js-light'),
prepend = doT.template($('#prepend_tmpl').html()),
template = doT.template($('#build_tmpl').html()),
previous;
var delayedUpdate = debounce(function(html, data) {
// Switch skin
skin = data.skin;
$.each(skins, function(i, s) {
$('#styles_' + s).prop('disabled', s !== skin);
});
// Render preview
preview.attr('class', preview.attr('class').replace(/(preview_)\w+/, '$1' + data.type));
preview.html(html);
preview.find('.social-likes').socialLikes();
form.find('.js-experimental').toggleClass('is-hidden', !experimental);
store.set(lang, {
skin: skin,
type: data.type,
counters: !!data.counters,
light: !!data.light,
title: data.title,
url: data.url,
site_facebook: !!data.site_facebook,
site_mailru: !!data.site_mailru,
site_odnoklassniki: !!data.site_odnoklassniki,
site_plusone: !!data.site_plusone,
site_twitter: !!data.site_twitter,
site_pinterest: !!data.site_pinterest,
site_vkontakte: !!data.site_vkontakte,
twitter_related: data.twitter_related,
twitter_via: data.twitter_via,
pinterest_media: data.pinterest_media
});
});
var loadOptions = function() {
var data = store.get(lang);
if (data) fillForm(form, data);
};
function update() {
var dataString = form.serialize();
if (dataString !== previous) {
var data = escapeFormData(form.serializeObject());
data.experimental = experimental;
twitterExtra.toggleClass('is-hidden', data.site_twitter !== '1');
pinterestExtra.toggleClass('is-hidden', data.site_pinterest !== '1');
lightStyle.toggleClass('is-hidden', data.skin !== 'flat');
var html = cleanHtml(template(data));
code.html(highlight(prepend(data) + html));
delayedUpdate(html, data);
downloadData.html = html;
downloadData.skin = data.skin;
previous = dataString;
}
}
loadOptions();
form.on('change input', 'input', update);
update();
form.submit(function() {
return false;
});
$('.js-download').click(download);
}
});
}(jQuery));

72
gh-pages/js/mylibs/htmlhl.js

@ -0,0 +1,72 @@
/* Author: Artem Sapegin, http://sapegin.me, 2012 */
/*jshint browser:true, jquery:true, white:false, smarttabs:true, eqeqeq:true,
immed:true, latedef:true, newcap:true, undef:true */
/*global jQuery:false, define:false*/
(function (factory) { // Try to register as an anonymous AMD module
if (typeof define === 'function' && define.amd) {
define([], factory);
} else {
factory();
}
}(function () {
'use strict';
var regexps = [
[/<(\/?)([\w]+)([^>]*)>/g, '←<$1→←tag:$2→$3←>→'], // Tag
[/ ([\-\w]+)/g, ' ←attr:$1→'] // Attribute
],
saveStringsRe = [
/"([^"]+)"/mg
],
restoreStringsRe = /↑(\d+)↓/g,
savedStrings,
savedStringsNum;
function save_strings(code) {
function save(s) {
savedStrings[savedStringsNum] = s;
return '↑' + savedStringsNum++ + '↓';
}
savedStringsNum = 0;
savedStrings = [];
for (var reIdx = 0; reIdx < saveStringsRe.length; reIdx++) {
code = code.replace(saveStringsRe[reIdx], save);
}
return code;
}
function restore_strings(code) {
code = code.replace(restoreStringsRe, function(s, num) {
return savedStrings[num];
});
savedStringsNum = 0;
savedStrings = [];
return code;
}
function highlight(code) {
code = save_strings(code);
for (var regexpIdx = 0; regexpIdx < regexps.length; regexpIdx++) {
var re = regexps[regexpIdx];
code = code.replace(re[0], re[1]);
}
code = restore_strings(code);
code = code.replace(/\=("[^\"]*")/g, '←=→←str:$1→'); // Attribute values
return code;
}
function htmlize(code) {
return code
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/←([^:→]+)→/g, '←gray:$1→')
.replace(/←(\w+):([^→]+)→/g, '<span class="hl-$1">$2</span>')
;
}
return (window.htmlhl = function(code) {
return htmlize(highlight(code));
});
}));

15
gh-pages/proxy/proxy.php

@ -0,0 +1,15 @@
<?php
try {
$content = base64_decode($_POST['content']);
if (empty($content)) throw new Exception();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="social-likes.zip"');
echo $content;
}
catch (Exception $e) {
header('HTTP/1.0 400 Bad request');
echo 'Bad request.';
}
?>

166
gh-pages/styles/gh-page.styl

@ -0,0 +1,166 @@
/* Author: Artem Sapegin, http://sapegin.me, 2012 */
link-color = #cf6c0a;
visited-color = #7c579e;
hover-color = #ff6900;
noise = url('../img/noise.png');
body {
background:#fff;
color:#111;
font-size:18px;
line-height:1.4;
min-width:1024px;
}
.wrapper {
position:relative;
max-width:1100px;
margin:0 auto;
padding:2*spacer;
}
// Fonts
* { font-family:"Helvetica Neue", Tahoma, sans-serif; }
pre, code, pre span { font-family:Consolas, "Lucida Console", Monaco, "Courier New", Courier, monospace; }
// Links