add main layout;
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,503 @@
|
||||
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-core.js
|
||||
********************************************** */
|
||||
|
||||
/**
|
||||
* Prism: Lightweight, robust, elegant syntax highlighting
|
||||
* MIT license http://www.opensource.org/licenses/mit-license.php/
|
||||
* @author Lea Verou http://lea.verou.me
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
// Private helper vars
|
||||
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
|
||||
|
||||
var _ = self.Prism = {
|
||||
util: {
|
||||
type: function (o) {
|
||||
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
|
||||
},
|
||||
|
||||
// Deep clone a language definition (e.g. to extend it)
|
||||
clone: function (o) {
|
||||
var type = _.util.type(o);
|
||||
|
||||
switch (type) {
|
||||
case 'Object':
|
||||
var clone = {};
|
||||
|
||||
for (var key in o) {
|
||||
if (o.hasOwnProperty(key)) {
|
||||
clone[key] = _.util.clone(o[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return clone;
|
||||
|
||||
case 'Array':
|
||||
return o.slice();
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
},
|
||||
|
||||
languages: {
|
||||
extend: function (id, redef) {
|
||||
var lang = _.util.clone(_.languages[id]);
|
||||
|
||||
for (var key in redef) {
|
||||
lang[key] = redef[key];
|
||||
}
|
||||
|
||||
return lang;
|
||||
},
|
||||
|
||||
// Insert a token before another token in a language literal
|
||||
insertBefore: function (inside, before, insert, root) {
|
||||
root = root || _.languages;
|
||||
var grammar = root[inside];
|
||||
var ret = {};
|
||||
|
||||
for (var token in grammar) {
|
||||
|
||||
if (grammar.hasOwnProperty(token)) {
|
||||
|
||||
if (token == before) {
|
||||
|
||||
for (var newToken in insert) {
|
||||
|
||||
if (insert.hasOwnProperty(newToken)) {
|
||||
ret[newToken] = insert[newToken];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret[token] = grammar[token];
|
||||
}
|
||||
}
|
||||
|
||||
return root[inside] = ret;
|
||||
},
|
||||
|
||||
// Traverse a language definition with Depth First Search
|
||||
DFS: function(o, callback) {
|
||||
for (var i in o) {
|
||||
callback.call(o, i, o[i]);
|
||||
|
||||
if (_.util.type(o) === 'Object') {
|
||||
_.languages.DFS(o[i], callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
highlightAll: function(async, callback) {
|
||||
var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
|
||||
|
||||
for (var i=0, element; element = elements[i++];) {
|
||||
_.highlightElement(element, async === true, callback);
|
||||
}
|
||||
},
|
||||
|
||||
highlightElement: function(element, async, callback) {
|
||||
// Find language
|
||||
var language, grammar, parent = element;
|
||||
|
||||
while (parent && !lang.test(parent.className)) {
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
language = (parent.className.match(lang) || [,''])[1];
|
||||
grammar = _.languages[language];
|
||||
}
|
||||
|
||||
if (!grammar) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set language on the element, if not present
|
||||
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
||||
|
||||
// Set language on the parent, for styling
|
||||
parent = element.parentNode;
|
||||
|
||||
if (/pre/i.test(parent.nodeName)) {
|
||||
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
|
||||
}
|
||||
|
||||
var code = element.textContent;
|
||||
|
||||
if(!code) {
|
||||
return;
|
||||
}
|
||||
|
||||
code = code.replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/\u00a0/g, ' ');
|
||||
//console.time(code.slice(0,50));
|
||||
|
||||
var env = {
|
||||
element: element,
|
||||
language: language,
|
||||
grammar: grammar,
|
||||
code: code
|
||||
};
|
||||
|
||||
_.hooks.run('before-highlight', env);
|
||||
|
||||
if (async && self.Worker) {
|
||||
var worker = new Worker(_.filename);
|
||||
|
||||
worker.onmessage = function(evt) {
|
||||
env.highlightedCode = Token.stringify(JSON.parse(evt.data));
|
||||
env.element.innerHTML = env.highlightedCode;
|
||||
|
||||
callback && callback.call(env.element);
|
||||
//console.timeEnd(code.slice(0,50));
|
||||
_.hooks.run('after-highlight', env);
|
||||
};
|
||||
|
||||
worker.postMessage(JSON.stringify({
|
||||
language: env.language,
|
||||
code: env.code
|
||||
}));
|
||||
}
|
||||
else {
|
||||
env.highlightedCode = _.highlight(env.code, env.grammar)
|
||||
env.element.innerHTML = env.highlightedCode;
|
||||
|
||||
callback && callback.call(element);
|
||||
|
||||
_.hooks.run('after-highlight', env);
|
||||
//console.timeEnd(code.slice(0,50));
|
||||
}
|
||||
},
|
||||
|
||||
highlight: function (text, grammar) {
|
||||
return Token.stringify(_.tokenize(text, grammar));
|
||||
},
|
||||
|
||||
tokenize: function(text, grammar) {
|
||||
var Token = _.Token;
|
||||
|
||||
var strarr = [text];
|
||||
|
||||
var rest = grammar.rest;
|
||||
|
||||
if (rest) {
|
||||
for (var token in rest) {
|
||||
grammar[token] = rest[token];
|
||||
}
|
||||
|
||||
delete grammar.rest;
|
||||
}
|
||||
|
||||
tokenloop: for (var token in grammar) {
|
||||
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var pattern = grammar[token],
|
||||
inside = pattern.inside,
|
||||
lookbehind = !!pattern.lookbehind || 0;
|
||||
|
||||
pattern = pattern.pattern || pattern;
|
||||
|
||||
for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
|
||||
|
||||
var str = strarr[i];
|
||||
|
||||
if (strarr.length > text.length) {
|
||||
// Something went terribly wrong, ABORT, ABORT!
|
||||
break tokenloop;
|
||||
}
|
||||
|
||||
if (str instanceof Token) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pattern.lastIndex = 0;
|
||||
|
||||
var match = pattern.exec(str);
|
||||
if (match) {
|
||||
if(lookbehind) {
|
||||
lookbehind = match[1].length;
|
||||
}
|
||||
|
||||
var from = match.index - 1 + lookbehind,
|
||||
match = match[0].slice(lookbehind),
|
||||
len = match.length,
|
||||
to = from + len,
|
||||
before = str.slice(0, from + 1),
|
||||
after = str.slice(to + 1);
|
||||
|
||||
var args = [i, 1];
|
||||
|
||||
if (before) {
|
||||
args.push(before);
|
||||
}
|
||||
|
||||
var wrapped = new Token(token, inside? _.tokenize(match, inside) : match);
|
||||
|
||||
args.push(wrapped);
|
||||
|
||||
if (after) {
|
||||
args.push(after);
|
||||
}
|
||||
|
||||
Array.prototype.splice.apply(strarr, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strarr;
|
||||
},
|
||||
|
||||
hooks: {
|
||||
all: {},
|
||||
|
||||
add: function (name, callback) {
|
||||
var hooks = _.hooks.all;
|
||||
|
||||
hooks[name] = hooks[name] || [];
|
||||
|
||||
hooks[name].push(callback);
|
||||
},
|
||||
|
||||
run: function (name, env) {
|
||||
var callbacks = _.hooks.all[name];
|
||||
|
||||
if (!callbacks || !callbacks.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i=0, callback; callback = callbacks[i++];) {
|
||||
callback(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var Token = _.Token = function(type, content) {
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
};
|
||||
|
||||
Token.stringify = function(o) {
|
||||
if (typeof o == 'string') {
|
||||
return o;
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(o) == '[object Array]') {
|
||||
return o.map(Token.stringify).join('');
|
||||
}
|
||||
|
||||
var env = {
|
||||
type: o.type,
|
||||
content: Token.stringify(o.content),
|
||||
tag: 'span',
|
||||
classes: ['token', o.type],
|
||||
attributes: {}
|
||||
};
|
||||
|
||||
if (env.type == 'comment') {
|
||||
env.attributes['spellcheck'] = 'true';
|
||||
}
|
||||
|
||||
_.hooks.run('wrap', env);
|
||||
|
||||
var attributes = '';
|
||||
|
||||
for (var name in env.attributes) {
|
||||
attributes += name + '="' + (env.attributes[name] || '') + '"';
|
||||
}
|
||||
|
||||
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
|
||||
|
||||
};
|
||||
|
||||
if (!self.document) {
|
||||
// In worker
|
||||
self.addEventListener('message', function(evt) {
|
||||
var message = JSON.parse(evt.data),
|
||||
lang = message.language,
|
||||
code = message.code;
|
||||
|
||||
self.postMessage(JSON.stringify(_.tokenize(code, _.languages[lang])));
|
||||
self.close();
|
||||
}, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get current script and highlight
|
||||
var script = document.getElementsByTagName('script');
|
||||
|
||||
script = script[script.length - 1];
|
||||
|
||||
if (script) {
|
||||
_.filename = script.src;
|
||||
|
||||
if (document.addEventListener && !script.hasAttribute('data-manual')) {
|
||||
document.addEventListener('DOMContentLoaded', _.highlightAll);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-markup.js
|
||||
********************************************** */
|
||||
|
||||
Prism.languages.markup = {
|
||||
'comment': /<!--[\w\W]*?--(>|>)/g,
|
||||
'prolog': /<\?.+?\?>/,
|
||||
'doctype': /<!DOCTYPE.+?>/,
|
||||
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
|
||||
'tag': {
|
||||
pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/gi,
|
||||
inside: {
|
||||
'tag': {
|
||||
pattern: /^<\/?[\w:-]+/i,
|
||||
inside: {
|
||||
'punctuation': /^<\/?/,
|
||||
'namespace': /^[\w-]+?:/
|
||||
}
|
||||
},
|
||||
'attr-value': {
|
||||
pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,
|
||||
inside: {
|
||||
'punctuation': /=|>|"/g
|
||||
}
|
||||
},
|
||||
'punctuation': /\/?>/g,
|
||||
'attr-name': {
|
||||
pattern: /[\w:-]+/g,
|
||||
inside: {
|
||||
'namespace': /^[\w-]+?:/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
'entity': /&#?[\da-z]{1,8};/gi
|
||||
};
|
||||
|
||||
// Plugin to make entity title show the real entity, idea by Roman Komarov
|
||||
Prism.hooks.add('wrap', function(env) {
|
||||
|
||||
if (env.type === 'entity') {
|
||||
env.attributes['title'] = env.content.replace(/&/, '&');
|
||||
}
|
||||
});
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-css.js
|
||||
********************************************** */
|
||||
|
||||
Prism.languages.css = {
|
||||
'comment': /\/\*[\w\W]*?\*\//g,
|
||||
'atrule': /@[\w-]+?(\s+[^;{]+)?(?=\s*{|\s*;)/gi,
|
||||
'url': /url\((["']?).*?\1\)/gi,
|
||||
'selector': /[^\{\}\s][^\{\}]*(?=\s*\{)/g,
|
||||
'property': /(\b|\B)[a-z-]+(?=\s*:)/ig,
|
||||
'string': /("|')(\\?.)*?\1/g,
|
||||
'important': /\B!important\b/gi,
|
||||
'ignore': /&(lt|gt|amp);/gi,
|
||||
'punctuation': /[\{\};:]/g
|
||||
};
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'style': {
|
||||
pattern: /(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,
|
||||
inside: {
|
||||
'tag': {
|
||||
pattern: /(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,
|
||||
inside: Prism.languages.markup.tag.inside
|
||||
},
|
||||
rest: Prism.languages.css
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-clike.js
|
||||
********************************************** */
|
||||
|
||||
Prism.languages.clike = {
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /("|')(\\?.)*?\1/g,
|
||||
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,
|
||||
'boolean': /\b(true|false)\b/g,
|
||||
'number': /\b-?(0x)?\d*\.?[\da-f]+\b/g,
|
||||
'operator': /[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,
|
||||
'ignore': /&(lt|gt|amp);/gi,
|
||||
'punctuation': /[{}[\];(),.:]/g
|
||||
};
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-javascript.js
|
||||
********************************************** */
|
||||
|
||||
Prism.languages.javascript = Prism.languages.extend('clike', {
|
||||
'keyword': /\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,
|
||||
'number': /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/g,
|
||||
});
|
||||
|
||||
Prism.languages.insertBefore('javascript', 'keyword', {
|
||||
'regex': {
|
||||
pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,
|
||||
lookbehind: true
|
||||
}
|
||||
});
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'script': {
|
||||
pattern: /(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,
|
||||
inside: {
|
||||
'tag': {
|
||||
pattern: /(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,
|
||||
inside: Prism.languages.markup.tag.inside
|
||||
},
|
||||
rest: Prism.languages.javascript
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* **********************************************
|
||||
Begin prism-coffeescript.js
|
||||
********************************************** */
|
||||
|
||||
Prism.languages.coffeescript = Prism.languages.extend('javascript', {
|
||||
'block-comment': /([#]{3}\s*\r?\n(.*\s*\r*\n*)\s*?\r?\n[#]{3})/g,
|
||||
'comment': /(\s|^)([#]{1}[^#^\r^\n]{2,}?(\r?\n|$))/g,
|
||||
'keyword': /\b(this|window|delete|class|extends|namespace|extend|ar|let|if|else|while|do|for|each|of|return|in|instanceof|new|with|typeof|try|catch|finally|null|undefined|break|continue)\b/g,
|
||||
});
|
||||
|
||||
Prism.languages.insertBefore('coffeescript', 'keyword', {
|
||||
'function': {
|
||||
pattern: /[a-z|A-z]+\s*[:|=]\s*(\([.|a-z\s|,|:|{|}|\"|\'|=]*\))?\s*->/gi,
|
||||
inside: {
|
||||
'function-name': /[_?a-z-|A-Z-]+(\s*[:|=])| @[_?$?a-z-|A-Z-]+(\s*)| /g,
|
||||
'operator': /[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g
|
||||
}
|
||||
},
|
||||
|
||||
'class-name': {
|
||||
pattern: /(class\s+)[a-z-]+[\.a-z]*\s/gi,
|
||||
lookbehind: true
|
||||
},
|
||||
|
||||
'attr-name': /[_?a-z-|A-Z-]+(\s*:)| @[_?$?a-z-|A-Z-]+(\s*)| /g
|
||||
});
|
||||
@@ -46,9 +46,14 @@
|
||||
a
|
||||
{
|
||||
color: $primaryColor;
|
||||
text-decoration: none;
|
||||
@extend %shortTransition;
|
||||
}
|
||||
|
||||
.article a
|
||||
{
|
||||
text-decoration: underline;
|
||||
outline: 1px dotted transparent;
|
||||
@extend %shortTransition;
|
||||
|
||||
&:link, &:hover, &:visited
|
||||
{
|
||||
|
||||
@@ -5,4 +5,6 @@ $darkColor: #1f2424;
|
||||
|
||||
$lightColor: #f4f8f8;
|
||||
|
||||
$textColor: #5e6161;
|
||||
$midColor: #5e6161;
|
||||
|
||||
$textColor: white;
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
@import "main";
|
||||
|
||||
@import "header";
|
||||
|
||||
@import "footer";
|
||||
@import "side";
|
||||
@@ -3,19 +3,29 @@
|
||||
@include box-sizing(border-box);
|
||||
}
|
||||
|
||||
$screen: "only screen";
|
||||
$small: "only screen and (max-width: 480px)";
|
||||
|
||||
html
|
||||
{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
html, body
|
||||
{
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
line-height: 1;
|
||||
line-height: 1.2;
|
||||
color: $textColor;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
font-family: 'Segoe UI', Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
background: $darkColor image-url('stripe.png') repeat-x top;
|
||||
|
||||
|
||||
-webkit-text-size-adjust: none;
|
||||
@@ -23,9 +33,27 @@ body
|
||||
-ms-touch-action: double-tap-zoom;
|
||||
}
|
||||
|
||||
html, body
|
||||
// app area
|
||||
.app
|
||||
{
|
||||
font-size: 100%;
|
||||
width: 760px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 100px 20px 0;
|
||||
position: relative;
|
||||
|
||||
@extend %clearfix;
|
||||
|
||||
@media #{$small}
|
||||
{
|
||||
padding-top: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.app-main
|
||||
{
|
||||
width: 460px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
// Get rid of gap under images by making them display: inline-block; by default
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
.app-side
|
||||
{
|
||||
width: 240px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.app-description
|
||||
{
|
||||
background: darken($darkColor, 2%);
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
@import "normalize";
|
||||
|
||||
@import "entypo";
|
||||
@import "entypo";
|
||||
|
||||
@import "prism";
|
||||
@@ -154,9 +154,9 @@
|
||||
//.entypo-quote:before {
|
||||
// content:"\275e"
|
||||
//}
|
||||
//.entypo-code:before {
|
||||
// content:"\e714"
|
||||
//}
|
||||
.entypo-code:before {
|
||||
content:"\e714"
|
||||
}
|
||||
//.entypo-export:before {
|
||||
// content:"\e715"
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: black;
|
||||
text-shadow: 0 1px white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
@media print {
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
text-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #f5f2f0;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #a67f59;
|
||||
background: hsla(0,0%,100%,.5);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
@@ -25,7 +25,294 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>PocketSharp</h1>
|
||||
<div class="app">
|
||||
|
||||
<aside class="app-side">
|
||||
<h1>
|
||||
<a href="/"><i class="entypo-code"></i>PocketSharp</a>
|
||||
</h1>
|
||||
<p class="app-description">
|
||||
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
|
||||
</p>
|
||||
</aside>
|
||||
|
||||
<div class="app-main">
|
||||
<article class="markdown-body entry-content" itemprop="mainContentOfPage"><h1>
|
||||
<a name="pocketsharp" class="anchor" href="#pocketsharp"><span class="octicon octicon-link"></span></a>PocketSharp</h1>
|
||||
|
||||
<blockquote>
|
||||
<p>This project is work in progress.
|
||||
PocketSharp will be released as a NuGet package when ready.</p>
|
||||
</blockquote>
|
||||
|
||||
<p><strong>PocketSharp</strong> is a C#.NET class library, that integrates the <a href="http://getpocket.com/developer">Pocket API v3</a> and consists of 4 parts:</p>
|
||||
|
||||
<ul>
|
||||
<li>Authentication</li>
|
||||
<li>Retrieve</li>
|
||||
<li>Modify</li>
|
||||
<li>Add</li>
|
||||
</ul><hr><p><em>If you don't know <a href="http://getpocket.com">Pocket</a>, be sure to check it out. It's an awesome service that lets you save articles, videos, ... in the cloud and access it from all your devices.</em></p>
|
||||
|
||||
<hr><h2>
|
||||
<a name="usage-example" class="anchor" href="#usage-example"><span class="octicon octicon-link"></span></a>Usage Example</h2>
|
||||
|
||||
<p>Request a <a href="http://getpocket.com/developer/apps/">Consumer Key on Pocket.</a></p>
|
||||
|
||||
<p>Include the PocketSharp namespace and it's associated models (you will need them later):</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">using</span> <span class="nn">PocketSharp</span><span class="p">;</span>
|
||||
<span class="k">using</span> <span class="nn">PocketSharp.Models</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Initialize PocketClient with:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">PocketClient</span> <span class="n">_client</span> <span class="p">=</span> <span class="k">new</span> <span class="n">PocketClient</span><span class="p">(</span><span class="s">"[YOUR_CONSUMER_KEY]"</span><span class="p">,</span> <span class="s">"[YOUR_ACCESS_CODE]"</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Do a simple request - e.g. a search for <code>CSS</code>:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">_client</span><span class="p">.</span><span class="n">Search</span><span class="p">(</span><span class="s">"css"</span><span class="p">).</span><span class="n">ForEach</span><span class="p">(</span>
|
||||
<span class="n">item</span> <span class="p">=></span> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">item</span><span class="p">.</span><span class="n">ID</span> <span class="p">+</span> <span class="s">" | "</span> <span class="p">+</span> <span class="n">item</span><span class="p">.</span><span class="n">Title</span><span class="p">)</span>
|
||||
<span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Which will output:</p>
|
||||
|
||||
<pre><code>330361896 | CSS Front-end Frameworks with comparison : By usabli.ca
|
||||
345541438 | Editr - HTML, CSS, JavaScript playground
|
||||
251743431 | CSS Architecture
|
||||
343693149 | CSS3 Transitions - Thank God We Have A Specification!
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<h2>
|
||||
<a name="create-an-instance" class="anchor" href="#create-an-instance"><span class="octicon octicon-link"></span></a>Create an instance</h2>
|
||||
|
||||
<p>Constructor:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">PocketClient</span><span class="p">(</span><span class="kt">string</span> <span class="n">consumerKey</span><span class="p">,</span> <span class="kt">string</span> <span class="n">accessCode</span> <span class="p">=</span> <span class="k">null</span><span class="p">,</span> <span class="n">Uri</span> <span class="n">callbackUri</span> <span class="p">=</span> <span class="k">null</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
<p><code>consumerKey</code>: The API key
|
||||
<br><code>accessCode</code>: Provide an access code if the user is already authenticated
|
||||
<br><code>callbackUri</code>: The callback URL is called by Pocket after authentication</p>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">PocketClient</span> <span class="n">_client</span> <span class="p">=</span> <span class="k">new</span> <span class="n">PocketClient</span><span class="p">(</span>
|
||||
<span class="n">consumerKey</span><span class="p">:</span> <span class="s">"123498237423498723498723"</span><span class="p">,</span>
|
||||
<span class="n">callbackUri</span><span class="p">:</span> <span class="k">new</span> <span class="n">Uri</span><span class="p">(</span><span class="s">"http://ceecore.com"</span><span class="p">),</span>
|
||||
<span class="n">accessCode</span><span class="p">:</span> <span class="s">"097809-oi987-izi8-jk98-oiuu89"</span>
|
||||
<span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>You can change the <em>Access Code</em> after initialization:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">_client</span><span class="p">.</span><span class="n">AccessCode</span> <span class="p">=</span> <span class="s">"[YOU_ACCESS_CODE]"</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
|
||||
<p><strong>Before authentication</strong> you will need to provide the <code>callbackUri</code> for authentication requests.
|
||||
<br><strong>After authentication</strong> you will need to provide the <code>accessCode</code>.</p>
|
||||
|
||||
<h2>
|
||||
<a name="authentication" class="anchor" href="#authentication"><span class="octicon octicon-link"></span></a>Authentication</h2>
|
||||
|
||||
<p>In order to communicate with a Pocket User, you will need a consumer key (which is generated by <a href="http://getpocket.com/developer/apps/">creating a new application on Pocket</a>) and an <strong>Access Code</strong>.</p>
|
||||
|
||||
<p>The authentication is a 3-step process:</p>
|
||||
|
||||
<h4>
|
||||
<a name="1-generate-authentication-uri" class="anchor" href="#1-generate-authentication-uri"><span class="octicon octicon-link"></span></a>1) Generate authentication URI</h4>
|
||||
|
||||
<p>Receive the <strong>request code</strong> and <strong>authentication URI</strong> from the library by calling <code>string GetRequestCode()</code>:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="kt">string</span> <span class="n">requestCode</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">GetRequestCode</span><span class="p">();</span>
|
||||
<span class="c1">// 0f453f2d-1605-8584-28fd-39af8e</span>
|
||||
<span class="n">Uri</span> <span class="n">authenticationUri</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">GenerateAuthenticationUri</span><span class="p">();</span>
|
||||
<span class="c1">// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&redirect_uri=http%253a%252f%252fceecore.com</span>
|
||||
</pre></div>
|
||||
|
||||
<p>The <em>request code</em> is stored internally, but you can also provide it as param in <code>GenerateAuthenticationUri(string requestCode = null)</code>.</p>
|
||||
|
||||
<h4>
|
||||
<a name="2-redirect-to-pocket" class="anchor" href="#2-redirect-to-pocket"><span class="octicon octicon-link"></span></a>2) Redirect to Pocket</h4>
|
||||
|
||||
<p>Next you need to redirect the user to the <code>authenticationUri</code>, which displays a prompt to grant permissions for the application (see image). After the user granted or denied, he/she is redirected to the <code>callbackUri</code>.</p>
|
||||
|
||||
<p><a href="https://raw.github.com/ceee/PocketSharp/master/PocketSharp/authentication-screen.png" target="_blank"><img src="https://raw.github.com/ceee/PocketSharp/master/PocketSharp/authentication-screen.png" alt="authentication screen" style="max-width:100%;"></a></p>
|
||||
|
||||
<h4>
|
||||
<a name="3-get-access-code" class="anchor" href="#3-get-access-code"><span class="octicon octicon-link"></span></a>3) Get Access Code</h4>
|
||||
|
||||
<p>Call <code>string GetAccessCode(string requestCode = null)</code></p>
|
||||
|
||||
<div class="highlight"><pre><span class="kt">string</span> <span class="n">accessCode</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">GetAccessCode</span><span class="p">();</span>
|
||||
<span class="c1">// fa8bfc16-69b3-4d22-7db7-84a58d</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Again, the received <em>access code</em> is stored internally.
|
||||
Note that <code>GetAccessCode</code> can only be called with an existing <em>request code</em>. If you need to re-authenticate a user, start again with Step 1).</p>
|
||||
|
||||
<h4>
|
||||
<a name="important" class="anchor" href="#important"><span class="octicon octicon-link"></span></a>Important</h4>
|
||||
|
||||
<p><strong>Be sure to permanently store the <em>Access Code</em> for your user.</strong>
|
||||
<br>
|
||||
Without it you would always have to redo the authentication process.</p>
|
||||
|
||||
<h2>
|
||||
<a name="retrieve" class="anchor" href="#retrieve"><span class="octicon octicon-link"></span></a>Retrieve</h2>
|
||||
|
||||
<p>Get list of all items:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">List</span><span class="p"><</span><span class="n">PocketItem</span><span class="p">></span> <span class="n">items</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">Retrieve</span><span class="p">();</span>
|
||||
<span class="c1">// equivalent to: _client.Retrieve(RetrieveFilter.All)</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Find items by a tag:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">List</span><span class="p"><</span><span class="n">PocketItem</span><span class="p">></span> <span class="n">items</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">SearchByTag</span><span class="p">(</span><span class="s">"tutorial"</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Find items by a search string:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">List</span><span class="p"><</span><span class="n">PocketItem</span><span class="p">></span> <span class="n">items</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">Search</span><span class="p">(</span><span class="s">"css"</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Find items by a filter:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">List</span><span class="p"><</span><span class="n">PocketItem</span><span class="p">></span> <span class="n">items</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">Retrieve</span><span class="p">(</span><span class="n">RetrieveFilter</span><span class="p">.</span><span class="n">Favorite</span><span class="p">);</span> <span class="c1">// only favorites</span>
|
||||
</pre></div>
|
||||
|
||||
<p>The RetrieveFilter Enum is specified as follows:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">enum</span> <span class="n">RetrieveFilter</span> <span class="p">{</span> <span class="n">All</span><span class="p">,</span> <span class="n">Unread</span><span class="p">,</span> <span class="n">Archive</span><span class="p">,</span> <span class="n">Favorite</span><span class="p">,</span> <span class="n">Article</span><span class="p">,</span> <span class="n">Video</span><span class="p">,</span> <span class="n">Image</span> <span class="p">}</span>
|
||||
</pre></div>
|
||||
|
||||
<h4>
|
||||
<a name="custom-parameters" class="anchor" href="#custom-parameters"><span class="octicon octicon-link"></span></a>Custom Parameters</h4>
|
||||
|
||||
<p>You can create a completely custom parameter list for retrieval with the POCO <code>RetrieveParameters</code>:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="kt">var</span> <span class="n">parameters</span> <span class="p">=</span> <span class="k">new</span> <span class="n">RetrieveParameters</span><span class="p">()</span>
|
||||
<span class="p">{</span>
|
||||
<span class="n">Count</span> <span class="p">=</span> <span class="m">50</span><span class="p">,</span>
|
||||
<span class="n">Offset</span> <span class="p">=</span> <span class="m">100</span><span class="p">,</span>
|
||||
<span class="n">Sort</span> <span class="p">=</span> <span class="n">SortEnum</span><span class="p">.</span><span class="n">oldest</span>
|
||||
<span class="p">...</span>
|
||||
<span class="p">};</span>
|
||||
|
||||
<span class="n">List</span><span class="p"><</span><span class="n">PocketItem</span><span class="p">></span> <span class="n">items</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">Retrieve</span><span class="p">(</span><span class="n">parameters</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<h2>
|
||||
<a name="add" class="anchor" href="#add"><span class="octicon octicon-link"></span></a>Add</h2>
|
||||
|
||||
<p>Adds a new item to your pocket list.
|
||||
Accepts four parameters, with <code>uri</code> being required.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">PocketItem</span> <span class="nf">Add</span><span class="p">(</span><span class="n">Uri</span> <span class="n">uri</span><span class="p">,</span> <span class="kt">string</span><span class="p">[]</span> <span class="n">tags</span> <span class="p">=</span> <span class="k">null</span><span class="p">,</span> <span class="kt">string</span> <span class="n">title</span> <span class="p">=</span> <span class="k">null</span><span class="p">,</span> <span class="kt">string</span> <span class="n">tweetID</span> <span class="p">=</span> <span class="k">null</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="n">PocketItem</span> <span class="n">newItem</span> <span class="p">=</span> <span class="n">_client</span><span class="p">.</span><span class="n">Add</span><span class="p">(</span>
|
||||
<span class="k">new</span> <span class="nf">Uri</span><span class="p">(</span><span class="s">"http://www.neowin.net/news/full-build-2013-conference-sessions-listing-revealed"</span><span class="p">),</span>
|
||||
<span class="k">new</span> <span class="kt">string</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"microsoft"</span><span class="p">,</span> <span class="s">"neowin"</span><span class="p">,</span> <span class="s">"build"</span> <span class="p">}</span>
|
||||
<span class="p">);</span>
|
||||
</pre></div>
|
||||
|
||||
<p>The title can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</p>
|
||||
|
||||
<p>If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id (with the tweetID). This allows Pocket to show the original tweet alongside the article.</p>
|
||||
|
||||
<h2>
|
||||
<a name="modify" class="anchor" href="#modify"><span class="octicon octicon-link"></span></a>Modify</h2>
|
||||
|
||||
<p>All Modify methods accept either the itemID (as int) or a <code>PocketItem</code> as parameter.</p>
|
||||
|
||||
<p>Archive the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.Archive(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<p>Un-archive the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.Unarchive(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<p>Favorites the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.Favorite(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<p>Un-favorites the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.Unfavorite(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<p>Deletes the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.Delete(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<h4>
|
||||
<a name="modify-tags" class="anchor" href="#modify-tags"><span class="octicon octicon-link"></span></a>Modify tags</h4>
|
||||
|
||||
<p>Add tags to the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.AddTags(myPocketItem, new string[] { "css", "2013" });
|
||||
</code></pre>
|
||||
|
||||
<p>Remove tags from the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.RemoveTags(myPocketItem, new string[] { "css", "2013" });
|
||||
</code></pre>
|
||||
|
||||
<p>Remove all tags from the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.RemoveTags(myPocketItem);
|
||||
</code></pre>
|
||||
|
||||
<p>Replaces all existing tags with new ones for the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.ReplaceTags(myPocketItem, new string[] { "css", "2013" });
|
||||
</code></pre>
|
||||
|
||||
<p>Renames a tag for the specified item:</p>
|
||||
|
||||
<pre><code>bool isSuccess = _client.RenameTag(myPocketItem, "oldTagName", "newTagName");
|
||||
</code></pre>
|
||||
|
||||
<hr><h2>
|
||||
<a name="release-history" class="anchor" href="#release-history"><span class="octicon octicon-link"></span></a>Release History</h2>
|
||||
|
||||
<ul>
|
||||
<li>2013-07-07 v0.3.1 authentication fixes</li>
|
||||
<li>2013-07-02 v0.3.0 update authentication process </li>
|
||||
<li>2013-06-27 v0.2.0 add, modify item & modify tags</li>
|
||||
<li>2013-06-26 v0.1.0 authentication & retrieve functionality</li>
|
||||
</ul><h2>
|
||||
<a name="used-packages" class="anchor" href="#used-packages"><span class="octicon octicon-link"></span></a>Used Packages</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://restsharp.org/">RestSharp</a></li>
|
||||
<li><a href="https://github.com/ServiceStack/ServiceStack.Text">ServiceStack.Text</a></li>
|
||||
</ul><h2>
|
||||
<a name="contributors" class="anchor" href="#contributors"><span class="octicon octicon-link"></span></a>Contributors</h2>
|
||||
|
||||
<table>
|
||||
<tbody><tr>
|
||||
<th><a href="http://twitter.com/artistandsocial" title="Follow @artistandsocial on Twitter"><img src="https://a248.e.akamai.net/camo.github.com/8b2b8890a9b041956524da618a73be363c9fd955/687474703a2f2f67726176617461722e636f6d2f6176617461722f39633631623166343330373432356631326630356433616462393330626136363f733d3730" alt="twitter/artistandsocial" style="max-width:100%;"></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://github.com/ceee">Tobias Klika @ceee</a></td>
|
||||
</tr>
|
||||
</tbody></table></article>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/Debug/app.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user