pug-mixins¶
Installation¶
Manual¶
- Download the project from https://github.com/mondeja/pug-mixins/archive/master.zip
- Copy
src
folder in your project rename it as you want.
Command line¶
Linux¶
git clone https://github.com/mondeja/pug-mixins.git
cp -r pug-mixins/src mixins && rm -rf pug-mixins
You can see a directory named mixins
, inside of which the library is located. You can rename it and copy inside your project and include the files.
Windows¶
git clone https://github.com/mondeja/pug-mixins.git
xcopy pug-mixins\src mixins
rmdir "pug-mixins" /S /Q
You can see a directory named mixins
, inside of which the library is located. You can rename it and copy inside your project and include the files.
Basic usage¶
Only include a file for use mixins located inside. You can do this specyfing pug includes at the beggining of your template.
For example if I have a file called example.pug
inside src/
folder and I need to use +script
mixin located at src/html/script.pug
:
include ./html/script.pug
See also
Custom contexts¶
Some mixins needs to pass specific locals at compilation script. For example, mixin +table-json()
needs a context with require
NodeJS function. The library includes some contexts in src/contexts.js
which can be imported in your preprocessing script:
-
pug_mixins_context
¶ All context included in
contexts.js
file merged in one context.
-
require_context
¶ Context with only
require
NodeJS function:{require: require}
.
Reference¶
View source code on Githubaudio/
— Podcasts and playlists ¶
ivoox.pug
– Ivoox podcasts players
¶
View source code on Github
Audios¶
mixin ivoox-audio(id)
- src = `https://www.ivoox.com/player_ej_${id}_4_1.html?`
- if ("c1" in attributes)
- c1 = attributes.c1;
- delete attributes.c1;
- src = src + `c1=${c1}`
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(frameborder="0"
allowfullscreen="true"
scrolling="no"
src=`${src}`
width="100%"
height="200")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+ivoox-audio
(id)(c1=null, width="100%", height="200")¶ Embed an audio from Ivoox.
Arguments: - id (string, integer) – Audio identificator. You can get it from the url of an audio page:
https://www.ivoox.com/...audios-mp3_rf_<THIS_NUMBER>_1.html
. - c1 (string, optional) – Main color of the embedded player in HEX format without
#
character. As defaultnull
(default Ivoox main color will be used:"FF6600"
).
- id (string, integer) – Audio identificator. You can get it from the url of an audio page:
Usage¶
Input
+ivoox-audio(25288583)(c1="007300")
Output
<iframe frameborder="0" allowfullscreen="true" scrolling="no" src="https://www.ivoox.com/player_ej_25288583_4_1.html?c1=007300" width="100%" height="200"></iframe>
Render
Podcasts¶
mixin ivoox-podcast(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://www.ivoox.com/player_es_podcast_${id}_1.html`
frameborder="0"
allowfullscreen="0"
scrolling="no"
width="100%"
height="440")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+ivoox-podcast
(id)(width="100%", height="440")¶ Embed a podcast from Ivoox.
Arguments: - id (string) – Podcast identificator. You can get it from the url of a podcast page:
https://www.ivoox.com/..._sq_f1<THIS_NUMBER>_1.html
.
- id (string) – Podcast identificator. You can get it from the url of a podcast page:
Usage¶
Input
+ivoox-podcast(70523)
Output
<iframe src="https://www.ivoox.com/player_es_podcast_70523_1.html" frameborder="0" allowfullscreen="0" scrolling="no" width="100%", height="440"></iframe>
Render
Playlists¶
mixin ivoox-playlist(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://www.ivoox.com/player_es_channel_${id}_1.html`
frameborder="0"
allowfullscreen="0"
scrolling="no"
width="100%"
height="440")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+ivoox-playlist
(id)(width="100%", height="440")¶ Insert an Ivoox channel playlist.
Arguments: - id (integer, string) – Your channel identificator. You can obtain it from your channel page url:
https://www.ivoox.com/..._nq_<THIS_NUMBER>_1.html
.
- id (integer, string) – Your channel identificator. You can obtain it from your channel page url:
Usage¶
Input
+ivoox-playlist(40562)
Output
<iframe src="https://www.ivoox.com/player_es_channel_40562_1.html" frameborder="0" allowfullscreen="0" scrolling="no" width="100%" height="440"></iframe>
Render
Channel subscription widget¶
mixin ivoox-channel-subscription(id)
- src = `https://www.ivoox.com/_ns_${id}_0_.html?`
- if ("c1" in attributes)
- c1 = attributes.c1;
- delete attributes.c1;
- src = src + `c1=${c1}&`
- if ("c2" in attributes)
- c2 = attributes.c2;
- delete attributes.c2;
- src = src + `c2=${c2}&`
- if ("r" in attributes)
- r = attributes.r;
- delete attributes.r;
- src = src + `r=${r}&`
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`${src}`
frameborder="0"
scrolling="no"
allowfullscreen="true"
height="174")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+ivoox-channel-subscription
(id)(c1="555555", c2="ffffff", r=null, height="174")¶ Insert an Ivoox subscription widget.
Arguments: - id (integer, string) – Your channel identificator. You can obtain it from your channel page url:
https://www.ivoox.com/..._nq_<THIS_NUMBER>_1.html
. - c1 (string) – Widget background color with HEX format without
#
character. As default"555555"
. - c1 – Widget text color with HEX format without
#
character. As default"ffffff"
.
- id (integer, string) – Your channel identificator. You can obtain it from your channel page url:
Usage¶
+ivoox-channel-subscription(40562)(c1="007300", c2="ffffff")
<iframe src="https://www.ivoox.com/_ns_40562_0_.html?c1=007300&c2=ffffff" frameborder="0" scrolling="no" allowfullscreen="true" height="174"></iframe>
soundcloud.pug
– Soundcloud podcasts players ¶
View source code on GithubEmbed Soundcloud user¶
mixin soundcloud-user(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("color" in attributes)
- color = attributes.color;
- delete attributes.color;
- else
- color = "ff8800";
- if ("auto_play" in attributes)
- auto_play = attributes.auto_play;
- delete attributes.auto_play;
- else
- auto_play = false;
- if ("hide_related" in attributes)
- hide_related = attributes.hide_related;
- delete attributes.hide_related;
- else
- hide_related = false;
- if ("show_comments" in attributes)
- show_comments = attributes.show_comments;
- delete attributes.show_comments;
- else
- show_comments = true;
- if ("show_user" in attributes)
- show_user = attributes.show_user;
- delete attributes.show_user;
- else
- show_user = true;
- if ("show_reposts" in attributes)
- show_reposts = attributes.show_reposts;
- delete attributes.show_reposts;
- else
- show_reposts = false;
- if ("show_teaser" in attributes)
- show_teaser = attributes.show_teaser;
- delete attributes.show_teaser;
- else
- show_teaser = true;
iframe(src=`https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/users/${id}&color=%23${color}&auto_play=${auto_play}&hide_related=${hide_related}&show_comments=${show_comments}&show_user=${show_user}&show_reposts=${show_reposts}&show_teaser=${show_teaser}`
width="100%"
height="300"
scrolling="no"
frameborder="no"
allow="autoplay")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+soundcloud-user
(id)(color="ff8800", auto_play=false, hide_related=false, show_comments=true, show_user=true, show_reposts=false, show_teaser=true, width="100%", height="300")¶ Arguments: - id (string) – Soundcloud user identificator. You can get it from an user Soundcloud page url.
- color (string) – Player color passed as HEX color withour
#
character. - autoplay (bool) – Play tracklist when content is loaded. As default
false
. - hide_related (bool) – Hide related content if
true
. As defaultfalse
. - show_comments (bool) – Show user comments on displayed tracks. As default
true
. - show_user – Show uploader name. As default
true
. - show_reposts (bool) – Show reposts. As default
false
. - show_teaser (bool) – Show teaser. As default
true
.
Usage¶
Input
+soundcloud-user("alvaromondejar")(show_comments=false)
Output
<iframe src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/users/alvaromondejar&color=%23ff8800&auto_play=false&hide_related=false&show_comments=false&show_user=true&show_reposts=false&show_teaser=true" width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay"></iframe>
Render
blog/
— Blogging tools ¶
storify.pug
- Storify stories¶
View source code on Github
Embed stories¶
mixin storify(user, slug)
- if ("border" in attributes)
- border = attributes.border;
- delete attributes.border;
- else
- border = false;
- if ("post_title" in attributes)
- post_title = attributes.post_title;
delete attributes.post_title;
- else
- post_title = slug.replace("-", " ")
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
.storify
iframe(src=`https://storify.com/${user}/${slug}/embed?border=${border}`
width="100%" height="750" frameborder="no" allowtransparency="true")
script(src=`https://storify.com/${user}/${slug}.js?border=${border}`)
- if (alt)
noscript
| [
a(href=`https://storify.com/${user}/${slug}` target="__blank") View the story "#{post_title}" on Storify
| ]
-
+storify
(user, slug)(border=false, post_title=null, width="100%", height="750")¶ Embed a story from Storify.
Arguments: - user (string) – Story publisher username.
- slug (string) – Story identificator. You can obtain it from a story page url.
- border (bool, optional) – Specify
border
parameter value insrc
endpoint of includediframe
. As defaultfalse
. - post_title (string, optional) – Post title used if
alt
istrue
. Note that if user browser supportsiframe
tags, this title will not be shown. If you don’t pass this parameter, this will be calculated fromslug
usingslug.replace("-", " ")
. As defaultnull
.
Usage¶
+storify("journalstarnews", "2018-lincoln-marathon")(alt=false)
<div class="storify">
<iframe src="https://storify.com/journalstarnews/2018-lincoln-marathon/embed?border=false" width="100%" height="750" frameborder="no" allowtransparency="true"></iframe>
<script src="https://storify.com/journalstarnews/2018-lincoln-marathon.js?border=false"></script>
</div>
board/
— Content-boards ¶
livebinders.pug
- Livebinders boards¶
View source code on GithubBinders by iframes¶
mixin livebinder(id)
- if ("present" in attributes)
- present = attributes.present;
- delete attributes.present;
- else
- present = true;
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://www.livebinders.com/play/play?id=${id}&present=${present}`
frameborder="0")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+livebinder
(id)(present=true)¶ Insert a content-board from Livebinders.
Arguments: - id (integer, string) – Identificator of the binder. You can obtain it from a binder page url.
Usage¶
Input
+livebinder(2368302)(width="100%", height="400")
Output
<iframe src="https://www.livebinders.com/play/play?id=2368302&present=true" frameborder="0" width="100%" height="400">Your browser does not support iframes.</iframe>
Render
padlet.pug
– Content boards from Padlet
¶
View source code on GithubInsert boards¶
mixin padlet(id)
- if ("header" in attributes || "footer" in attributes)
- iframe_only = false
- else
- iframe_only = true
- if ("header" in attributes)
- header = true;
- delete attributes.header;
- else
- header = false;
- if ("footer" in attributes)
- footer = true;
- delete attributes.footer;
- else
- footer = false;
- if (iframe_only)
iframe(src=`https://padlet.com/embed/${id}`
frameborder="0")&attributes(attributes)
- else
- if (header)
.padlet-embed(style="border:1px solid rgba(0,0,0,0.1);border-radius:2px;box-sizing:border-box;overflow:hidden;position:relative;width:100%;background:#F4F4F4")&attributes(attributes)
- else
.padlet-embed(style="overflow:hidden;position:relative;")
p(style="padding:0;margin:0")
iframe(src=`https://padlet.com/embed/${id}`
frameborder="0")&attributes(attributes)
- if (footer)
div(style="padding:8px;text-align:right;margin:0;")
a(href="https://padlet.com?ref=embed"
style="padding:0;margin:0;border:none;display:block;line-height:1;height:16px"
target="_blank")
img(src="https://resources.padletcdn.com/assets/made_with_padlet.png"
width="86" height="16"
style="padding:0;margin:0;background:none;border:none;display:inline;box-shadow:none"
alt="Made with Padlet")
-
+padlet
(id)(header=false, footer=false)¶ Include a content board from Padlet.
Arguments: - id (string) – Board identificator.
- header (bool, optional) – If
true
, include the header. As defaultfalse
. - footer (bool, optional) – If
true
, include the footer. As defaultfalse
.
Usage¶
Input
+padlet("v8nee7607dvc")(width="100%", height="600")
Output
<iframe src="https://padlet.com/embed/v8nee7607dvc" frameborder="0" width="100%" height="600"></iframe>
Render
code/
— Programming tools ¶
codepen.pug
– Modern pens ¶
View source code on GithubEmbed pens¶
mixin codepen(id, user)
- if ("default_tab" in attributes)
- default_tab = attributes.default_tab;
- delete attributes.default_tab;
- else
- default_tab = "result";
- if ("embed_version" in attributes)
- embed_version = attributes.embed_version;
- delete attributes.embed_version;
- else
- embed_version = 2;
- src = `http://codepen.io/${user}/embed/${id}/?default-tab=${default_tab}&embed-version=${embed_version}`
- if ("theme_id" in attributes)
- theme_id = attributes.theme_id;
- delete attributes.theme_id;
- src = src + `&theme-id=${theme_id}`
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(scrolling="no"
frameborder="0"
allowtransparency="true"
allowfullscreen="true"
src=`${src}`
width="100%"
height="300")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+codepen
(id, user)(default_tab="result", embed_version=2, theme_id=null, width="100%", height="400")¶ Embed a pen from Codepen passing a pen identificator and their user.
Note
You can obtain identificator and user of a pen from the url of their page. For example: https://codepen.io/
user
/pen/id
.Arguments: - id (string) – Pen id.
- user (string) – Pen user.
- default_tab (string, optional) – Tab shown after the pen is loaded. As default
"result"
. - embed_version (integer, string, optional) – Codepen embed API version used for current insertion. As default
2
. - theme_id (integer, string, optional) – Identificator of your customized theme. You can create your own theme from Codepen Embed Theme Builder.
Usage¶
Input
+codepen("ZameGP", "mondeja")(theme_id=33136)
Output
<iframe src="http://codepen.io/mondeja/embed/ZameGP/?default-tab=result&embed-version=2&theme-id=33136" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" width="100%" height="300"></iframe>
Render
console.pug
– Insert consoles everywhere ¶
View source code on GithubBrython console¶
mixin brython-console()
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src="http://brython.info/console.html"
scrolling="no"
width="75%"
height="165")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+brython-console
()(width="75%" height="165")¶ Embed a Python console iframe made with Brython for the browser.
Usage¶
Input
+brython-console()
Output
<iframe width="75%" height="165" src="http://brython.info/console.html"></iframe>
Render
Javascript console ¶
mixin js-console()
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src="https://jsconsole.com/"
width="75%"
height="165")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+js-console
()(width="75%" height="165")¶ Embed a Javascript console iframe from http://jsconsole.com/.
Usage¶
Input
+js-console()
Output
<iframe width="75%" height="165" src="https://jsconsole.com/"></iframe>
Render
gist.pug
– Github gists mixins ¶
View source code on GithubEmbed gists¶
mixin gist(user, id)
- if (id.length != 32)
- throw new Error("Invalid gist id length. Must be 32 but is " + id.length)
script(src=`https://gist.github.com/${user}/${id}.js`)&attributes(attributes)
-
+gist
(user, id)¶ Embed a gist passing their user and identificator. You can obtain these parameters from the gist page url.
Arguments: - user (string) – Gist owner username.
- id (string) – Gist identificator
Usage¶
Input
gist("mondeja", "2bd82917552ff2589ddffc4a92744825")
Output
<script src="https://gist.github.com/mondeja/2bd82917552ff2589ddffc4a92744825.js"></script>
Render
jsfiddle.pug
– JsFiddle web editor ¶
View source code on GithubFiddles¶
mixin jsfiddle(user, id)
- src = `https://jsfiddle.net/${user}/${id}/embedded/`
- if ("tabs" in attributes)
- tabs = attributes.tabs;
- delete attributes.tabs;
- else
- tabs = "js,html,css,result";
- src = src + tabs + "/"
- if ("theme" in attributes)
- theme = attributes.theme;
- delete attributes.theme;
- else
- theme = "light";
- src = src + theme + "/?";
- _first_color_param = false;
- if ("font_color" in attributes)
- font_color = attributes.font_color;
- delete attributes.font_color;
- src = src + "fontColor=" + font_color;
- _first_color_param = true;
- if ("accent_color" in attributes)
- accent_color = attributes.accent_color;
- delete attributes.accent_color;
- if (_first_color_param)
- src = src + "&"
- src = src + "accentColor=" + accent_color;
- _first_color_param = true;
- if ("code_background" in attributes)
- code_background = attributes.code_background;
- delete attributes.code_background;
- if (_first_color_param)
- src = src + "&"
- src = src + "codeBackground=" + code_background;
- _first_color_param = true;
- if ("menu_background" in attributes)
- menu_background = attributes.menu_background;
- delete attributes.menu_background;
- if (_first_color_param)
- src = src + "&"
- src = src + "menuBackground=" + menu_background;
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`${src}`
allowpaymentrequest="true"
allowfullscreen="true"
width="100%"
height="400"
frameborder="0")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+jsfiddle
(user, id)(tabs="js, html, css, result", theme="light", font_color=null, accent_color=null, code_background=null, menu_background=null, width="100%", height="400")¶ Embed a fiddle from JsFiddle.
Arguments: - user (string) – Owner username of the fiddle.
- id (string) – Fiddle identificator. You can extract it from url of the fiddle page.
- tabs (string) – Tabs shown in the fiddle, separated by commas. By default, all:
"js,html,css,result"
. - theme (string) – Fiddle theme. Valid are
"light"
and"dark"
. As default"light"
.
Note
Parameters
font_color
,accent_color
,code_background
andmenu_background
accept HEX colors string without#
starting character.
Usage¶
Input
+jsfiddle("mondeja", "xf3tvvw0")(tabs="html,css,result", theme="dark")
Output
<iframe src="https://jsfiddle.net/mondeja/xf3tvvw0/embedded/html,css,result/dark/" allowpaymentrequest="true" allowfullscreen="true" frameborder="0" width="100%" height="400"></iframe>
Render
pastebin.pug
– Clean Pastebin pastes ¶
View source code on GithubEmbed pastes¶
mixin pastebin(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://pastebin.com/embed_iframe/${id}`
width="100%"
height="315")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+pastebin
(id)¶ Insert a paste from Pastebin.
Arguments: - id (string) – Paste identificator, corresponds to some letters and numbers located at the end of a paste url. For example, if the url is https://pastebin.com/DHa6btr5, the identificator is
DHa6btr5
.
- id (string) – Paste identificator, corresponds to some letters and numbers located at the end of a paste url. For example, if the url is https://pastebin.com/DHa6btr5, the identificator is
Usage¶
Input
+pastebin("DHa6btr5")(width="100%" height="315")
Output
<iframe width="100%" height="315" src="https://pastebin.com/embed_iframe/DHa6btr5"></iframe>
Render
pythontutor.pug
– Code executions step by step¶
View source code on GithubInsert a PythonTutor iframe
¶
mixin tutor(lang="python")
- valid_langs = ["python", "c", "cpp", "java", "javascript", "ruby"];
- if (valid_langs.indexOf(lang) > 0)
- if (lang == "python")
- endpoint = "visualize";
- else
- endpoint = lang;
- else
- throw new Error(lang + " is not a valid language. Valid languages: " + valid_langs);
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(width="100%"
height="500"
frameborder="0"
src=`http://pythontutor.com/${endpoint}.html#cumulative=false&heapPrimitives=nevernest&mode=edit&origin=opt-frontend.js&py=3&rawInputLstJSON=%5B%5D&textReferences=false`)
- if (alt)
| Your browser does not support iframes.
-
+tutor
(lang="python")(width="100%", height="500")¶ Insert a PythonTutor
iframe
passing a language name as first parameter.Arguments: - lang (string) – Code language. Valid languages are:
"python"
,"c"
,"cpp"
,"java"
,"javascript"
,"ruby"
.
- lang (string) – Code language. Valid languages are:
Usage¶
Input
+tutor()
Output
<iframe width="100%" height="500" frameborder="0" src="http://pythontutor.com/visualize.html#cumulative=false&heapPrimitives=nevernest&mode=edit&origin=opt-frontend.js&py=3&rawInputLstJSON=%5B%5D&textReferences=false">Your browser does not support iframes.</iframe>
Render
shield.pug
– Developer shields ¶
View source code on GithubShields by urls¶
mixin shield-urls(image_url, target_url)
a(href=target_url target="__blank")&attributes(attributes)
img(src=image_url)
-
+shield-urls
(image_url, target_url)¶ Insert a shield passing the image url and link href.
Arguments: - image_url (string) – Image url of the shield.
- target_url (string) – Target url of the shield.
Usage¶
Input
+shield-urls("https://travis-ci.org/mondeja/pymarketcap.svg?branch=master", "https://cnhv.co/1xgw5")
Output
<a href="https://cnhv.co/1xgw5" target="__blank">
<img src="https://travis-ci.org/mondeja/pymarketcap.svg?branch=master">
</a>
Render
Shields by services¶
mixin shield(service, project_id)
- if (attributes)
- if ("branch" in attributes)
- branch = attributes.branch;
- delete attributes.branch;
- else
- branch = "master";
- if ("version" in attributes)
- version = attributes.version;
- delete attributes.version;
- else
- version = "latest";
- if ("url" in attributes)
- url = attributes.url;
- delete attributes.url;
- else
- url = null;
- else
- attributes = {};
- if (service == "travis")
- url = url || `https://travis-ci.org/${project_id}`;
+shield-urls(
`https://travis-ci.org/${project_id}.svg?branch=${branch}`,
`${url}`
)&attributes(attributes)
- else if (service == "pypi-version")
- url = url || `https://pypi.org/project/${project_id}`;
+shield-urls(
`https://img.shields.io/pypi/v/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "pypi-py-versions")
- url = url || `https://pypi.org/project/${project_id}`;
+shield-urls(
`https://img.shields.io/pypi/pyversions/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "pypi-status")
- url = url || `https://pypi.org/project/${project_id}`;
+shield-urls(
`https://img.shields.io/pypi/status/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "pypi-license")
- url = url || `https://pypi.org/project/${project_id}`;
+shield-urls(
`https://img.shields.io/pypi/l/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "binder")
- url = url || `https://mybinder.org/v2/gh/${project_id}/${branch}`;
+shield-urls(
`https://mybinder.org/badge.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "readthedocs" || service == "rtd")
- url = url || `http://${project_id}.readthedocs.io/`;
+shield-urls(
`https://readthedocs.org/projects/${project_id}/badge/?version=${version}`,
`${url}`
)&attributes(attributes)
- else if (service == "ask-me-anything")
- url = url || project_id;
+shield-urls(
`https://camo.githubusercontent.com/d52b9239d76d77ebff4fc954745ee8ba555338ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41736b2532306d652d616e797468696e672d3161626339632e737667`,
`${url}`
)&attributes(attributes)
- else if (service == "github-issues")
- url = url || `https://github.com/${project_id}/issues`;
+shield-urls(
`https://img.shields.io/github/issues/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "github-issues-closed")
- url = url || `https://github.com/${project_id}/issues?q=is%3Aissue+is%3Aclosed`;
+shield-urls(
`https://img.shields.io/github/issues-closed/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "github-issues-closed-in")
- url = url || `https://github.com/${project_id}/issues`;
+shield-urls(
`https://img.shields.io/issuestats/i/long/github/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "github-last-commit")
- url = url || `https://github.com/${project_id}/commits`;
+shield-urls(
`https://img.shields.io/github/last-commit/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "github-contributors")
- url = url || `https://github.com/${project_id}/graphs/contributors`;
+shield-urls(
`https://img.shields.io/github/contributors/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "isitmaintained-issues-open-perc")
- url = url || `http://isitmaintained.com/project/${project_id}`;
+shield-urls(
`http://isitmaintained.com/badge/open/${project_id}.svg`,
`${url}`
)&attributes(attributes)
- else if (service == "isitmaintained-issues-closed-in")
- url = url || `http://isitmaintained.com/project/${project_id}`;
+shield-urls(
`http://isitmaintained.com/badge/resolution/${project_id}.svg`,
`${url}`
)&attributes(attributes)
-
+shield
(service, project_id, url=null, branch=null, version=null)¶ Include shields passing, as minimum, their service and project id.
Arguments: - service (string) –
Shield service. Valid services are:
"travis"
: Insert a travis shield. Pass the parameterbranch
with a valid project branch or the branch used will be"master"
."pypi-version"
: Shield that shows version of a project hosted at Pypi defined byproject_id
parameter."pypi-py-version"
: Shows versions defined by a python project setup’s classifiers param hosted at Pypi."pypi-status"
: Shows a shield with status information of a project hosted at Pypi."pypi-license"
: Shows a shield with the license of a project hosted at Pypi."binder"
: Inserts a Binderhub shield that links to an IPython console for a repository. Pass the parameterbranch
with a valid project branch or the branch used will be"master"
. Only works for Github projects."readthedocs"
/"rtd"
: Insert a Readthedocs shield. You need to pass the optional argumentversion
, by default"latest"
will be used."ask-me-anything"
: Insert an “Ask me anything” shield. You need to pass the url link target in the optional parameterurl
."github-issues"
: Shows number of issues opened in a Github project."github-issues-closed"
: Shows number of issues closed in a Github project."github-issues-closed-in"
: Shows mean time spended closing a issue in a Github project."github-last-commit"
: Shows a shield with how many time has elapsed since last commit in a project."github-contributors"
: Shows number of contributors that have been participated in a project."isitmaintained-issues-open-perc"
: Shows the percentage of issues open against total issues. This data is provided by Isitmaintained and is useful to know if a project are currently been maintained."isitmaintained-issues-closed-in"
: Shows mean time spended closing a issue in a Github project provided by Isitmaintained.
- project_id (string) – Identificator of the project. Depends of service, some needs only a project name like the Pypi shields, but others like Github shields need a string including the repository author like
"mondeja/pug-mixins"
. Only ask yourself, this service works identificating their hosted projects by an author and project name or only needs the project name? - url (string, optional) – Target url of a shield. Can be used to replace manually default shields link targets. As default
null
. - branch (string, optional) – Branch of a project. As default
"master"
. - version (string, optional) – Version of the project. Is used only by
"readthedocs"
service for now. As defaultlatest
.
- service (string) –
Usage¶
Input
+shield("readthedocs", "pymarketcap")(version="latest")
Output
<a href="http://pymarketcap.readthedocs.io/" target="__blank">
<img src="https://readthedocs.org/projects/pymarketcap/badge/?version=latest">
</a>
Render
crypto/
— Blockchain utils ¶
coinbase.pug
– Cryptocurrencies payment processor ¶
View source code on GithubCoinbase allows customized easy payments processing with some cryptocurrencies like Bitcoin (BTC), Ethereum (ETH), Bitcoin Cash (BCH) and Litecoin (LTC).

In order to use all mixins explained in this page, you need to follow next steps:
- Go to Coinbase Commerce page, sign up and/or sign in.
- Go to Dashboard. At left-bottom corner of your screen must be a button with the text
Accept payments
, click it. - You can select between sell a product or accept donations. This option will change the process of payment.
- Customize your product or organization for donations and Coinbase will show you some code for embed it in your page. Search in the code the line
href="https://coinbase.commerce.com...
and copy the identificator located aftercheckout/
. This one must look like05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7
. Use this identification to pass it at first parameter of+coinbase
and+coinbase-default
mixins. - Go to Settings section and add the index url of your documentation to whitelisted domains list.
Coinbase Commerce script¶
mixin coinbase-script()
script(src="https://commerce.coinbase.com/v1/checkout.js")&attributes(attributes)
-
+coinbase-script
()¶ All coinbase commerce mixins doesn’t includes by default the necessary script that make works these payment implementations. You can include where you want with this mixin.
Custom links¶
mixin coinbase(id, span_text, include_script=false)
a(href=`https://commerce.coinbase.com/checkout/${id}`)&attributes(attributes)
span #{span_text}
- if (include_script)
script(src="https://commerce.coinbase.com/v1/checkout.js")
-
+coinbase
(id, span_text, include_script=false)¶ Insert a link to your product/organization without any style.
Arguments: - id (string) – Your product indentificator, as explained above.
- span_text (string) – Text of the link.
- include_script (bool, string) – Interaction with coinbase commerce only is possible including a script. You can pass
include_script=true
to include it after the link, but maybe you prefer include inside in yourhead
scripts section (see+coinbase-script()
mixin above). As default,"false"
.
Usage¶
Input
+coinbase("05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7", "Siglo25 donations")
Output
<a href="https://commerce.coinbase.com/checkout/05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7"><span>Siglo25 donations</span></a>
Render
Siglo25 donationsInput
a(href=`https://commerce.coinbase.com/checkout/05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7`) My basic link
Output
<a href="https://commerce.coinbase.com/checkout/05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7">My basic link</a>
Render
My basic linkDefault links¶
mixin coinbase-default(id, span_text, include_script=false)
a.donate-with-crypto(href=`https://commerce.coinbase.com/checkout/${id}`)&attributes(attributes)
span #{span_text}
- if (include_script)
script(src="https://commerce.coinbase.com/v1/checkout.js")
-
+coinbase-default
(id, span_text, include_script=false)¶ Insert a link that will be styled like a button with Coinbase colors palette.
Arguments: - id (string) – Your product indentificator, as explained above.
- span_text (string) – Text of the button.
- include_script (bool, string) – Interaction with coinbase commerce only is possible including a script. You can pass
include_script=true
to include it after the link, but maybe you prefer include inside in yourhead
scripts section (see+coinbase-script()
mixin above). As default,"false"
.
Usage¶
Input
+coinbase-default("05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7", "Siglo25 donations", include_script="true")
Output
<a class="donate-with-crypto" href="https://commerce.coinbase.com/checkout/05bc9951-75aa-4c8a-b0f4-aadc0f9ad3e7">
<span>Siglo25 donations</span>
</a>
<script src="https://commerce.coinbase.com/v1/checkout.js">
Render
Siglo25 donationsfunctional/
— Functional programming ¶
loop.pug
– Recursive HTML generation ¶
View source code on Githubhtml/
— HTML tags utilities ¶
ol.pug
– Ordered lists generation ¶
View source code on GithubOrdered list from string¶
mixin ol-string(value, separator=",")
ol&attributes(attributes)
each elem in value.split(separator)
li #{elem}
-
+ol-string
(value, separator=", ")¶ Insert a ordered list from a string indicating a separator to split the string.
Arguments: - value (string) – String from which the list will be built.
- separator (string) – The string will be splitted into differents elements using a separator passed as value of this parameter. As default
","
.
Usage¶
Input
+ol-string("one,two,three,four,five")
Output
<ol>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
</ol>
Render
- one
- two
- three
- four
- five
script.pug
– Powerful script
macros ¶
View source code on GithubLoad external scripts¶
mixin script(src)
script(src=`${src}`
type="text/javascript"
charset="utf-8")&attributes(attributes)
-
+script
(src)¶ Insert an external script avoiding to specify
type
andcharset
HTML attributes.Arguments: - src (string) – External script src.
Usage¶
Input
+script("path/to/file.js")(async defer)
Output
<script src="path/to/file.js" type="text/javascript" charset="UTF-8" async defer>
table.pug
– Tables generation ¶
View source code on GithubTable from JSON matrix¶
mixin table-json(src, header=true)
//- requires context --> {require: require}
- matrix_table = require(src);
- count = 0;
table&attributes(attributes)
each row in matrix_table
tr
each column in row
- if (count == 0)
- if (header == true)
th #{column}
- else
td #{column}
- else
td #{column}
- count += 1;
-
+table-json
(src, header=true)¶ Note
This mixin requires
require_context
inyection.Create a table indicating a JSON file path which has a two level matrix structure (arrays inside arrays) like:
[ [1, 2, 3, 4, 5], [1, 2, 3, 4, 5] ]
Arguments: - src (string) – Path of the
.json
file to load. - header (bool, optional) – Indicates if include
th
tags for the first row. As defaulttrue
.
- src (string) – Path of the
Usage¶
Inputs
[
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]
]
+table-json("data.json")(style="width:50%;")
Output
<table style="width:50%;">
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
</table>
Render
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 |
ul.pug
– Unordered lists generation ¶
View source code on GithubUnordered list from string¶
mixin ul-string(value, separator=",")
ul&attributes(attributes)
each elem in value.split(separator)
li #{elem}
-
+ul-string
(value, separator=", ")¶ Insert an unordered list from a string indicating a separator to split the string.
Arguments: - value (string) – String from which the list will be built.
- separator (string) – The string will be splitted into differents elements using a separator passed as value of this parameter. As default
","
.
Usage¶
Input
+ul-string("one,two,three,four,five")
Output
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
</ul>
Render
- one
- two
- three
- four
- five
map/
— Customized maps ¶
google.pug
– Embed Google Maps ¶
View source code on Github
In order to use the next mixins, you need to follow next steps:
- Go to Maps Javascript API Google’s documentation and get an API key. You can start the process for obtain it clicking on
GET STARTED
button. - In your API’s google dashboard you must enable next APIs:
Note
Mixins explained in this page are covering Google Maps Embed API Documentation and there is the relation between mixins and maps types:
google-map-view()
:view
mode.google-map-place()
:place
mode.
Common parameters¶
-
+google-map-*
(key)(maptype="roadmap")¶ All google maps mixins share some common parameters like:
Arguments: - key (string) – Your API key. Don’t forget to enable Google Maps APIs as explained above because if aren’t enabled, the iframe will not be displayed.
- maptype (string, optional) –
As default,
"roadmap"
. You can selected between 2 styles of map:"roadmap"
: View of predetermined road map."satellite"
: View of satellital images of Google Earth.
Embed maps by places¶
mixin google-map-place(query, key)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if (query.length == 27 && query.indexOf(["+"]) < 1)
- query = "place_id:" + query
- else
- query = query.replace(/ /g, "+");
iframe(src=`https://google.com/maps/embed/v1/place?key=${key}&q=${query}`
frameborder="0"
width="100%"
height="450")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+google-map-place
(query, key)(maptype="roadmap")¶ Insert a Google map given a place string like
"Eiffel Tower,Paris France"
or by place identificator.Arguments: - query (string) – Place string or place identificator. You can pass it with spaces and the mixins will be responsible of replace all with
"+"
characters. - key (string) – See Common parameters.
- maptype (string, optional) – See Common parameters.
- query (string) – Place string or place identificator. You can pass it with spaces and the mixins will be responsible of replace all with
Usage¶
Input
+google-map-place("Eiffel Tower,Paris France", "AIzaSyAYBpeIr5j02T63_xtKTs3l5vC8eLsNqqI")
Output
<iframe src="https://google.com/maps/embed/v1/place?key=AIzaSyAYBpeIr5j02T63_xtKTs3l5vC8eLsNqqI&q=Eiffel+Tower,Paris+France" frameborder="0" width="100%" height="450">Your browser does not support iframes.</iframe>
Render
Embed maps by coordinates¶
mixin google-map-view(center, zoom, key)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("maptype" in attributes)
- maptype = attributes.maptype;
- delete attributes.maptype;
- else
- maptype = "roadmap";
- src = `https://google.com/maps/embed/v1/view?key=${key}¢er=${center}&zoom=${zoom}&maptype=${maptype}`
- if ("language" in attributes)
- src = src + `&language=${attributes.language}`;
- delete attributes.language;
- if ("region" in attributes)
- src = src + `®ion=${attributes.region}`;
- delete attributes.region;
iframe(frameborder="0"
width="100%"
height="450"
src=`${src}`)&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+google-map-view
(center, zoom, key)(maptype="roadmap", language=null, region=null, width="100%", height="450")¶ Insert a Google map given location coordinates, a zoom distance and API key parameters. You can configure also map visualization type displayed when
iframe
content is loaded.Arguments: - center (string) – Coordinates separatted by a comma. These can be obtained navigating through maps at maps.google.com. You can see in the url the coordinates at the right of a
@
symbol. The parameter in the url that contains az
caracter is the zoom (see parameter). - zoom (float, string) – The higher will be this value, the distance to the earth will be less and viceversa.
- key (string) – See Common parameters.
- maptype (string, optional) – See Common parameters.
- language (string) – Defines the language to use for UI elements and for the display of labels on map tiles. By default, visitors will see a map in their own language.
- region (string) – defines the appropriate borders and labels to display, based on geo-political sensitivities. Accepts a region code specified as a two-character ccTLD (top-level domain) value.
- center (string) – Coordinates separatted by a comma. These can be obtained navigating through maps at maps.google.com. You can see in the url the coordinates at the right of a
Usage¶
Input
+google-map-view("36.0135723,-5.6080321", 9.5, "AIzaSyAYBpeIr5j02T63_xtKTs3l5vC8eLsNqqI")(maptype="satellite")
Output
<iframe frameborder="0" width="100%" height="450" src="https://www.google.com/maps/embed/v1/view?key=AIzaSyAYBpeIr5j02T63_xtKTs3l5vC8eLsNqqI¢er=36.0135723,-5.6080321&zoom=9.5&maptype=satellite"></iframe>
Render
nodemap/
— Nodegraph maps ¶
bubbl.pug
– Mind maps from Bubbl¶
View source code on GithubEmbed graph maps¶
mixin bubbl-map(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://bubbl.us/${id}?utm_source=page-embed&utm_medium=link&s=9040282`
allowfullscreen="true"
frameborder="0"
width="100%"
height="400")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+bubbl-map
(id)(width="100%", height="400")¶ Insert a mental map based on graphs nodes from https://bubbl.us
Arguments: - id (string) – Map identificator.
Usage¶
Input
+bubbl-map("NDcxMTQ1Ny85MDQwMjgyL2U5YTM3MWQyZTJlZDhkODdiOWNlMjRmYzg0MWFlYzIz-X")
Output
<iframe src="https://bubbl.us/NDcxMTQ1Ny85MDQwMjgyL2U5YTM3MWQyZTJlZDhkODdiOWNlMjRmYzg0MWFlYzIz-X?utm_source=page-embed&utm_medium=link&s=9040282 allowfullscreen="true" frameborder="0" width="100%" height="400"></iframe>
Render
video/
— Videos and playlists ¶
dailymotion.pug
– Dailymotion video iframes¶
View source code on GithubEmbed videos¶
mixin dailymotion-video(id, autoplay=false)
- if (autoplay == true)
- _autoplay = 1
- else
- _autoplay = 0
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(frameborder="0"
width="480"
height="270"
src=`https://www.dailymotion.com/embed/video/${id}?autoPlay=${_autoplay}`
allowfullscreen="true"
allow="autoplay")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+dailymotion-video
(id, autoplay=false)(width="480" height="270")¶ Embed a Dailymotion video.
Arguments: - id (string) – Identificator of the video. You can obtain it from their url.
- autoplay – Indicates if the video is played after loading. As default
false
.
Usage¶
Input
+dailymotion-video("x2c3xfh")(width="100%", height="360")
Output
<iframe frameborder="0" width="100%" height="360" src="https://www.dailymotion.com/embed/video/x2c3xfh?autoPlay=0" allowfullscreen="true" allow="autoplay"></iframe>
Render
vimeo.pug
– Vimeo video iframes ¶
View source code on GithubEmbed videos¶
mixin vimeo-video(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
iframe(src=`https://player.vimeo.com/video/${id}`
frameborder="0"
width="640"
height="360"
allowfullscreen)&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+vimeo-video
(id)(width="640", height="360")¶ Insert a Vimeo video
iframe
given a identificator.Arguments: - id (string / integer) – Video identificator, correspond to a number located at the end of a video url. For example, if a video has the url https://vimeo.com/96425312, the identificator is
96425312
.
- id (string / integer) – Video identificator, correspond to a number located at the end of a video url. For example, if a video has the url https://vimeo.com/96425312, the identificator is
Usage¶
Input
+vimeo-video("152881306")(width="100%" height="315")
Output
<iframe width="100%" height="315" src="https://player.vimeo.com/video/152881306" frameborder="0" allowfullscreen></iframe>
Render
youtube.pug
– Youtube videos and playlists ¶
View source code on Github
Embed videos¶
mixin youtube-video(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("autoplay" in attributes)
- autoplay = attributes.autoplay;
- delete attributes.autoplay;
- else
- autoplay = false;
- if (autoplay == true)
- autoplay = 1;
- else
- autoplay = 0;
- src = `https://www.youtube.com/embed/${id}?autoplay=${autoplay}`
iframe(src=`${src}`
frameborder="0"
allow="autoplay;encrypted-media"
allowfullscreen="true"
width="560"
height="315")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+youtube-video
(id)(autoplay=false, width="560", height="315")¶ Insert a Youtube video
iframe
given a identificator.Arguments: - id (string) – Video identificator, corresponds to some letters and numbers located at the end of a video url. For example, if a video has the url https://www.youtube.com/watch?v=xK1bZBzowF0, the identificator is
xK1bZBzowF0
. - autoplay (bool, optional) – If
true
, video will be inmediatly played after loaded.
- id (string) – Video identificator, corresponds to some letters and numbers located at the end of a video url. For example, if a video has the url https://www.youtube.com/watch?v=xK1bZBzowF0, the identificator is
Usage¶
Input
+youtube-video("xK1bZBzowF0")(width="100%")
Output
<iframe width="100%" height="315" src="https://www.youtube.com/embed/xK1bZBzowF0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Render
Embed playlists¶
mixin youtube-playlist(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("autoplay" in attributes)
- autoplay = attributes.autoplay;
- delete attributes.autoplay;
- else
- autoplay = false;
- if (autoplay == true)
- autoplay = 1;
- else
- autoplay = 0;
iframe(src=`https://www.youtube.com/embed/videoseries?list=${id}&autoplay=${autoplay}`
frameborder="0"
allow="autoplay;encrypted-media"
allowfullscreen="true"
width="560"
height="315")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+youtube-playlist
(id)(width="560", height="315")¶ Insert a Youtube playlist
iframe
given an identificator.Arguments: - id (string) – Playlist identificator, corresponds to some letters and numbers located at the end of a playlist url. For example, if a playlist has the url https://www.youtube.com/playlist?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d, the identificator is
PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d
.
- id (string) – Playlist identificator, corresponds to some letters and numbers located at the end of a playlist url. For example, if a playlist has the url https://www.youtube.com/playlist?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d, the identificator is
Usage¶
Input
+youtube-playlist("PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d")(width="100%")
Output
<iframe width="100%" height="315" src="https://www.youtube.com/embed/videoseries?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Render
Contributing¶
Basic guidelines¶
- Fork the project from https://github.com/mondeja/pug-mixins
- Download the source code from github with
git clone https://github.com/<your-user>/pug-mixins.git
or manually fromhttps://github.com/<your-user>/pug-mixins/archive/master.zip
. - Install python dependencies with
pip install -r requirements.txt
. - Fix a bug or create a new feature (and write tests if this is your case).
- Run tests with
make tests
orpytest test
. If something is broken, fix it. - Write documentation for this new features if necessary and build it. See doc/ – Writing documentation.
- Commit your changes and pull
git pull origin master
. - Make a pull request from the github interface. See CI testing for your pull request. If something is broken, fix it and restart the pull request.
See also
Project directories tree¶
src
: Source code of the project. All mixins are catalogued by folders according to their use, not by html tags.doc
: Project documentation. See doc/ – Writing documentation.test
: Project tests wrote withpytest
. See test/ – Testing.scripts
: Useful scripts. You can see here a python script calleddoc_prebuild.py
that loads source code mixins and insert on documentation through jinja2 renderization.
doc/
– Writing documentation¶
Documentation for each new module must be located at doc/source/_templates/
. This folder has the same directories structure of src/
. If you see the existing templates you will observe that mixins source code are included by their name, replacing -
caracters with _
and enclosed by double {
and }
caracters.
Build steps¶
The script located at scripts/prebuild_doc.py
render all source code mixins in their respective files. Execute it normally or use make doc-prebuild
(Linux/Mac users).
Generated output files will be located at doc/source/user_guide/modules/
. This files need to be referenced from doc/source/user_guide/reference.rst
toctrees.
So the build documentation process involves 2 steps, first prebuild with previously explained script and the build process with sphinx
. You can execute this 2 steps secuentially running make doc-build
.
Mixins structure¶
Please, respect documentation structure for each mixin. These must include, at least, the next information in order:
- Source code of the mixin.
- Mixin documentation (description, attributes…)
- Usage example with:
- Input example.
- HTML output of that example.
- Renderization output.
test/
– Testing¶
Note
To run tests you need to install python dependencies with pip install -r requirements.txt
and pug client with npm install pug
.
- run tests:
pytest tests
Writing tests¶
Every new feature need to be tested. All tests are located in test/
, and this have the same project structure than src/
, but all names are preceded by test_
.
At the beggining of every test, set in global variables: filepath of .pug
source file to test and directory located in.
The basic process of each test involves next steps:
- Create a
.pug
page inside project source directory that will be tested. This page must contains a mixin execution string and an include pointing to the mixins source code that will be tested (in the same folder). Seepug_utils.create_pug_page()
. - Renderize created pug page and test HTML output.
- If possible, test web endpoints (see
http_utils
below).
Fixtures¶
Pytest fixtures are inyected from test/conftest.py
and located at test/_fixtures/
.
pug_utils.py
¶
-
pug_utils.
create_pug_page
(src, content, includes=[])¶ Creates a pug page with the content provided inserting includes to files in the same folder.
Parameters: Returns: src
parameter value.Return type:
http_utils.py
¶
-
class
http_utils.
Response
(text, status_code, url)¶ Represents HTTP response objects.
Parameters:
-
http_utils.
get
(url, timeout=10)¶ Performs a GET request giving an url as first parameter.
Parameters:
-
http_utils.
assert_200
(url)¶ Assert if requesting with GET an url this returns 200 status code.
Parameters: url (str) – Request url. Returns: Response object if is asserted True
.Return type: http_utils.Response
-
http_utils.
assert_403
(url)¶ Assert if requesting with GET an url this returns 403 HTTP error (Forbidden request).
Parameters: url (str) – Request url. Returns: Response object if is asserted True
.Return type: http_utils.Response
Global variables¶
Global tests variables are located at _fixtures/constests.py
module.
constests.py
¶
-
PUG_CLI_PATH
¶ Filepath of pug client.
-
*_DIR
You can get every directory path inside
src/
folder importing fromconftest.py
the uppercase name of a src folder following by_DIR
. For example, filepath ofsrc/code
is the value ofCODE_DIR
.
Development status ¶
audio/
— Podcasts and playlists ¶
ivoox.pug
– Ivoox podcasts players
¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+ivoox-audio() |
|||
+ivoox-podcast() |
|||
+ivoox-playlist() |
|||
+ivoox-channel-subscription() |
|||
+ivoox-podcast-subscription() |
Advanced¶
+ivoox-audio()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+ivoox-podcast()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+ivoox-playlist()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+ivoox-channel-subscription()
- Default
height
parameter -
alt
parameter support - HTTP endpoint tested
- Default
+ivoox-podcast-subscription()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Understand and explain at documentation what really does
r
optional parameter of+ivoox-channel-subscription()
mixin. - Develop
+ivoox-podcast-subscription()
mixin.
soundcloud.pug
– Soundcloud podcasts players ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+soundcloud-user() |
Advanced¶
+soundcloud-user()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
blog/
— Blogging tools ¶
storify.pug
- Storify stories¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+storify() |
Advanced¶
+storify()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Explain better what does
border
parameter of+storify()
mixin.
code/
— Programming tools ¶
codepen.pug
– Modern pens ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+codepen() |
Advanced¶
+codepen()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Add
test_codepen_invalid()
test. - Add
test_codepen_default_tab
test. - Add
test_codepen_invalid_default_tab
test. - Add
test_codepen_embed_version
test. - Add
test_codepen_invalid_embed_version
test.
console.pug
– Insert consoles everywhere ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+brython-console() |
|||
+js-console() |
Advanced¶
+brython-console()
- Default
width
andheight
parameters -
alt
parameter support - Test HTTP endpoint
- Default
+js-console()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Understand and explain at documentation what really does
r
optional parameter of+ivoox-channel-subscription()
mixin. - Develop
+ivoox-podcast-subscription()
mixin.
jsfiddle.pug
– JsFiddle web editor ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+jsfiddle() |
Advanced¶
+jsfiddle()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Test
tabs
parameter. - Test
theme
parameter. - Test
font_color
parameter. - Test
accent_color
parameter. - Test
code_background
parameter. - Test
menu_background
parameter.
pastebin.pug
– Clean Pastebin pastes ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+pastebin() |
Advanced¶
+pastebin()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
pythontutor.pug
– Code executions step by step¶
View source code on GithubTracking¶
TODO¶
- Implement paramters for Pythontutor
iframe
url.
shield.pug
– Developer shields ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+shield-urls() |
|||
+shield() |
Advanced¶
+shield()
- HTTP endpoints tested by services:
-
"travis"
-
"pypi-version"
-
"pypi-py-versions"
-
"pypi-status"
-
"pypi-license"
-
"binder"
-
"readthedocs"
-
"ask-me-anything"
-
"github-issues"
-
"github-issues-closed"
-
"github-issues-closed-in"
-
"github-last-commit"
-
"github-contributors"
-
"isitmaintained-issues-open-perc"
-
"isitmaintained-issues-closed-in"
-
crypto/
— Blockchain utils ¶
coinbase.pug
– Cryptocurrencies payment processor ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+coinbase-script() |
|||
+coinbase() |
|||
+coinbase-default() |
Advanced¶
+coinbase-script()
- HTTP endpoint tested
TODO¶
- Test
include_script
parameter.
functional/
— Functional programming ¶
html/
— HTML tags utilities ¶
ol.pug
– Ordered lists generation ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+ol-string() |
Advanced¶
+ol-string()
-
separator
parameter tested
-
table.pug
– Tables generation ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+table-json() |
Advanced¶
table-json()
-
header
optional parameter tested
-
ul.pug
– Unordered lists generation ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+ul-string() |
Advanced¶
+ul-string()
-
separator
parameter tested
-
map/
— Customized maps ¶
google.pug
– Embed Google Maps ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+google-map-view() |
|||
+google-map-place() |
Advanced¶
+google-map-view()
:- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+google-map-place()
:- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Optional parameters for attributes saving:
attribution_source
,attribution_web_url
andattribution_ios_deep_link_id
.
- Default
TODO¶
- Add
google-map-place()
mixin covering place mode of Google Maps Embed API. - Add
google-map-directions()
mixin covering directions mode of Google Maps Embed API. - Add
google-map-search()
mixin covering search mode of Google Maps Embed API. - Add
google-map-streetview()
mixin covering street view mode of Google Maps Embed API.
nodemap/
— Nodegraph maps ¶
bubbl.pug
– Mind maps from Bubbl¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+bubbl-map() |
Advanced¶
+bubbl-map()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
social/
— Connect with people ¶
facebook.pug
– Facebook tools ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+facebook-like() |
|||
+facebook-post() |
Advanced¶
+facebook-like()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+facebook-post()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
video/
— Videos and playlists ¶
dailymotion.pug
– Dailymotion video iframes¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+dailymotion-video() |
Advanced¶
+dailymotion-video()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
vimeo.pug
– Vimeo video iframes ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+vimeo-video() |
Advanced¶
+vimeo-video()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
youtube.pug
– Youtube videos and playlists ¶
View source code on GithubTracking¶
Basic¶
Mixin | Implemented | Tested | Documented |
---|---|---|---|
+youtube-video() |
|||
+youtube-playlist() |
Advanced¶
youtube-*()
- Optional parameters support:
-
autoplay
-
cc_load_policy
-
color
-
controls
-
disablekb
-
enablejsapi
-
end
-
fs
-
hl
-
iv_load_policy
-
loop
-
modestbranding
-
origin
-
playlist
-
playsinline
-
rel
-
showinfo
-
start
-
widget_referrer
-
+youtube-video()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
+youtube-playlist()
- Default
width
andheight
parameters -
alt
parameter support - HTTP endpoint tested
- Default
TODO¶
- Add
youtube-user-uploads()
mixin coveringLoading a user's uploaded videos
section of Youtube embedded players documentation. - Add
youtube-search()
mixin coveringLoading search results for a specified query
section of Youtube embedded players documentation.
Changelog¶
0.0.2¶
- :js:func`+google-map` mixin renamed as
+google-map-view()
. - New folders, files and mixins:
code/
pythontutor.pug
html/
ol.pug
table.pug
ul.pug
map/
google.pug
0.0.1¶
New folders, files and mixins:
audio/
blog/
storify.pug
board/
livebinders.pug
padlet.pug
code/
codepen.pug
console.pug
gist.pug
jsfiddle.pug
pastebin.pug
shield.pug
crypto/
coinbase.pug
functional/
loop.pug
html/
script.pug
map/
google.pug
+google-map()
nodemap/
bubbl.pug
social/
facebook.pug
video/
dailymotion.pug
vimeo.pug
youtube.pug
social/
— Connect with people ¶
View source code on Githubfacebook.pug
– Facebook tools ¶Like buttons¶
+facebook-like
(href)(layout="standard", action="like", size="small", show_faces=true, share=true, app_id=null, width="450", height="80")¶Creates a “like” facebook button pointing to content referenced by
href
parameter.See also
Facebook Like button documentation.
Select a design between next availables:
standard
(default): Minimum width225px
, default width450px
and height35px
(without photos) or80px
(with photos).button_count
: Minimum width55px
, default width55px
and height65px
.button
: Minimum width90px
, default width90px
and height20px
.box_count
: Minimum width47px
, default width47px
and height20px
."like"
and"recommend"
. As default"like"
."small"
and"big"
. As default"small"
."standard"
design). As defaulttrue
.iframe
element must be include a “Share” button. As defaulttrue
."light"
and"dark"
. As default"light"
.null
.Usage¶
Input
Output
Render
Embed posts¶
+facebook-post
(user_id, post_number)(app_id=null)(width="450", height="289")¶Insert a post given a post number and user identificators.
See also
Facebook embedded posts documentation.
facebook.com/
and/posts/
./posts/
in the url.null
.Usage¶
Input
Output
Render