From b18930d6b087269738d0d86b7bd9d08169a01339 Mon Sep 17 00:00:00 2001
From: Llewellyn van der Merwe
Date: Wed, 2 Nov 2016 02:19:25 +0200
Subject: [PATCH] Urgent announcement option added to the new sermon
distributor.
---
admin/README.txt | 66 +++++++
admin/models/fields/adminviewfolderlist.php | 167 ++++++++++++++++++
admin/models/fields/siteviewfolderlist.php | 167 ++++++++++++++++++
...sed_issues_the_closed_issues_on_github.php | 30 ++++
..._open_issues_the_open_issues_on_github.php | 30 ++++
.../tmpl/default_readme_information.php | 30 ++++
...t_vast_development_method_notice_board.php | 30 ++++
media/js/marked.js | 7 +
8 files changed, 527 insertions(+)
create mode 100644 admin/README.txt
create mode 100644 admin/models/fields/adminviewfolderlist.php
create mode 100644 admin/models/fields/siteviewfolderlist.php
create mode 100644 admin/views/sermondistributor/tmpl/default_closed_issues_the_closed_issues_on_github.php
create mode 100644 admin/views/sermondistributor/tmpl/default_open_issues_the_open_issues_on_github.php
create mode 100644 admin/views/sermondistributor/tmpl/default_readme_information.php
create mode 100644 admin/views/sermondistributor/tmpl/default_vast_development_method_notice_board.php
create mode 100644 media/js/marked.js
diff --git a/admin/README.txt b/admin/README.txt
new file mode 100644
index 00000000..82f28eae
--- /dev/null
+++ b/admin/README.txt
@@ -0,0 +1,66 @@
+# Sermon Distributor (1.3.4)
+
+ ![Sermon Distributor image](https://raw.githubusercontent.com/SermonDistributor/Joomla-3-Component/master/admin/assets/images/component-300.jpg "The Sermon Distributor")
+
+Distributor is a highly advanced sermon distributor that runs on the [Joomla 3.x](http://www.joomla.org) framework. You can link a shared folder from Dropbox to the component and use Dropbox as your file host, not to mention the advanced auto builder that gives you the ability to simply load sermons to your website by only adding them to Dropbox.
+
+The best way to see all your options is to install this component on you Joomla website and test all features yourself. Here is a [direct download link](https://github.com/SermonDistributor/Joomla-3-Component/archive/master.zip)
+
+ **If you like our component please rate it on the [Joomla Index](http://extensions.joomla.org/extensions/extension/living/religion/sermon-distributor)**
+
+### Example Website, That Has Over 6000 Audio Files
+
+[LoudVoice.org](http://www.loudvoice.org)
+
+### Some Video Demonstrations
+
++ [Setup overview](https://youtu.be/yMPp1Cp3W_0?t=20m8s)
++ [Setup Dropbox](https://youtu.be/btpKFDk0-dI)
+
+# Build Details
+
++ *Company*: [Vast Development Method](https://www.vdm.io/)
++ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@vdm.io)
++ *Name*: [Sermon Distributor](https://www.vdm.io/)
++ *First Build*: 22nd October, 2015
++ *Last Build*: 31st October, 2016
++ *Version*: 1.3.4
++ *Copyright*: Copyright (C) 2015. All Rights Reserved
++ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+## Build Time :hourglass:
+
+**140 Hours** or **18 Eight Hour Days** (actual time the author saved -
+due to [Automated Component Builder](https://www.vdm.io/joomla-component-builder))
+
+> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
+> never making one mistake or taking any coffee break.)
+
++ *Line count*: **50049**
++ *File count*: **364**
++ *Folder count*: **80**
+
+**92 Hours** or **11 Eight Hour Days** (the actual time the author spent)
+
+> (with the following break down:
+> **debugging @35hours** = codingtime / 4;
+> **planning @20hours** = codingtime / 7;
+> **mapping @14hours** = codingtime / 10;
+> **office @23hours** = codingtime / 6;)
+
+**232 Hours** or **29 Eight Hour Days**
+(a total of the realistic time frame for this project)
+
+> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
+> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)
+
+Project duration: **5.8 weeks** or **1.2 months**
+
+> This **component** was build with a Joomla [Automated Component Builder](https://www.vdm.io/joomla-component-builder).
+> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+
+## Donations
+
+ If you want to support this project, please consider donating:
+ * PayPal: pay@vdm.io
+ * Bitcoin: 3H35PYwikEosvcjxHXGPLS1GufZ4b4iFu3
\ No newline at end of file
diff --git a/admin/models/fields/adminviewfolderlist.php b/admin/models/fields/adminviewfolderlist.php
new file mode 100644
index 00000000..4955e428
--- /dev/null
+++ b/admin/models/fields/adminviewfolderlist.php
@@ -0,0 +1,167 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+// import the list field type
+jimport('joomla.form.helper');
+JFormHelper::loadFieldClass('list');
+
+/**
+ * Adminviewfolderlist Form Field class for the Sermondistributor component
+ */
+class JFormFieldAdminviewfolderlist extends JFormFieldList
+{
+ /**
+ * The adminviewfolderlist field type.
+ *
+ * @var string
+ */
+ public $type = 'adminviewfolderlist';
+ /**
+ * Override to add new button
+ *
+ * @return string The field input markup.
+ *
+ * @since 3.2
+ */
+ protected function getInput()
+ {
+ // see if we should add buttons
+ $setButton = $this->getAttribute('button');
+ // get html
+ $html = parent::getInput();
+ // if true set button
+ if ($setButton === 'true')
+ {
+ $button = array();
+ $script = array();
+ $buttonName = $this->getAttribute('name');
+ // get the input from url
+ $jinput = JFactory::getApplication()->input;
+ // get the view name & id
+ $values = $jinput->getArray(array(
+ 'id' => 'int',
+ 'view' => 'word'
+ ));
+ // check if new item
+ $ref = '';
+ $refJ = '';
+ if (!is_null($values['id']) && strlen($values['view']))
+ {
+ // only load referal if not new item.
+ $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
+ $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
+ }
+ $user = JFactory::getUser();
+ // only add if user allowed to create
+ if ($user->authorise('core.create', 'com_sermondistributor'))
+ {
+ // build Create button
+ $buttonNamee = trim($buttonName);
+ $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
+ $buttonNamee = ucfirst(strtolower($buttonNamee));
+ $button[] = '
+ ';
+ }
+ // only add if user allowed to edit
+ if (($buttonName == '' || $buttonName == '') && $user->authorise('core.edit', 'com_sermondistributor'))
+ {
+ // build edit button
+ $buttonNamee = trim($buttonName);
+ $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
+ $buttonNamee = ucfirst(strtolower($buttonNamee));
+ $button[] = '
+ ';
+ // build script
+ $script[] = "
+ jQuery(document).ready(function() {
+ jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
+ e.preventDefault();
+ var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
+ ".$buttonName."Button(".$buttonName."Value);
+ });
+ var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
+ ".$buttonName."Button(".$buttonName."Value);
+ });
+ function ".$buttonName."Button(value) {
+ if (value > 0) {
+ // hide the create button
+ jQuery('#".$buttonName."Create').hide();
+ // show edit button
+ jQuery('#".$buttonName."Edit').show();
+ var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
+ jQuery('#".$buttonName."Edit').attr('href', url);
+ } else {
+ // show the create button
+ jQuery('#".$buttonName."Create').show();
+ // hide edit button
+ jQuery('#".$buttonName."Edit').hide();
+ }
+ }";
+ }
+ // check if button was created for field.
+ if (is_array($button) && count($button) > 0)
+ {
+ // Load the needed script.
+ $document = JFactory::getDocument();
+ $document->addScriptDeclaration(implode(' ',$script));
+ // return the button attached to input field.
+ return '' .$html . implode('',$button).'
';
+ }
+ }
+ return $html;
+ }
+
+ /**
+ * Method to get a list of options for a list input.
+ *
+ * @return array An array of JHtml options.
+ */
+ public function getOptions()
+ {
+ // get custom folder files
+ $localfolder = JPATH_COMPONENT_ADMINISTRATOR.'/views';
+ // set the default
+ $options = array();
+ // import all needed classes
+ jimport('joomla.filesystem.folder');
+ // now check if there are files in the folder
+ if (JFolder::exists($localfolder) && $folders = JFolder::folders($localfolder))
+ {
+ foreach ($folders as $folder)
+ {
+ $options[] = JHtml::_('select.option', $folder, SermondistributorHelper::safeString($folder, 'W'));
+ }
+ }
+ return $options;
+ }
+}
diff --git a/admin/models/fields/siteviewfolderlist.php b/admin/models/fields/siteviewfolderlist.php
new file mode 100644
index 00000000..af432782
--- /dev/null
+++ b/admin/models/fields/siteviewfolderlist.php
@@ -0,0 +1,167 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+// import the list field type
+jimport('joomla.form.helper');
+JFormHelper::loadFieldClass('list');
+
+/**
+ * Siteviewfolderlist Form Field class for the Sermondistributor component
+ */
+class JFormFieldSiteviewfolderlist extends JFormFieldList
+{
+ /**
+ * The siteviewfolderlist field type.
+ *
+ * @var string
+ */
+ public $type = 'siteviewfolderlist';
+ /**
+ * Override to add new button
+ *
+ * @return string The field input markup.
+ *
+ * @since 3.2
+ */
+ protected function getInput()
+ {
+ // see if we should add buttons
+ $setButton = $this->getAttribute('button');
+ // get html
+ $html = parent::getInput();
+ // if true set button
+ if ($setButton === 'true')
+ {
+ $button = array();
+ $script = array();
+ $buttonName = $this->getAttribute('name');
+ // get the input from url
+ $jinput = JFactory::getApplication()->input;
+ // get the view name & id
+ $values = $jinput->getArray(array(
+ 'id' => 'int',
+ 'view' => 'word'
+ ));
+ // check if new item
+ $ref = '';
+ $refJ = '';
+ if (!is_null($values['id']) && strlen($values['view']))
+ {
+ // only load referal if not new item.
+ $ref = '&ref=' . $values['view'] . '&refid=' . $values['id'];
+ $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
+ }
+ $user = JFactory::getUser();
+ // only add if user allowed to create
+ if ($user->authorise('core.create', 'com_sermondistributor'))
+ {
+ // build Create button
+ $buttonNamee = trim($buttonName);
+ $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
+ $buttonNamee = ucfirst(strtolower($buttonNamee));
+ $button[] = '
+ ';
+ }
+ // only add if user allowed to edit
+ if (($buttonName == '' || $buttonName == '') && $user->authorise('core.edit', 'com_sermondistributor'))
+ {
+ // build edit button
+ $buttonNamee = trim($buttonName);
+ $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
+ $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
+ $buttonNamee = ucfirst(strtolower($buttonNamee));
+ $button[] = '
+ ';
+ // build script
+ $script[] = "
+ jQuery(document).ready(function() {
+ jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
+ e.preventDefault();
+ var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
+ ".$buttonName."Button(".$buttonName."Value);
+ });
+ var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
+ ".$buttonName."Button(".$buttonName."Value);
+ });
+ function ".$buttonName."Button(value) {
+ if (value > 0) {
+ // hide the create button
+ jQuery('#".$buttonName."Create').hide();
+ // show edit button
+ jQuery('#".$buttonName."Edit').show();
+ var url = 'index.php?option=com_sermondistributor&view=&task=.edit&id='+value+'".$refJ."';
+ jQuery('#".$buttonName."Edit').attr('href', url);
+ } else {
+ // show the create button
+ jQuery('#".$buttonName."Create').show();
+ // hide edit button
+ jQuery('#".$buttonName."Edit').hide();
+ }
+ }";
+ }
+ // check if button was created for field.
+ if (is_array($button) && count($button) > 0)
+ {
+ // Load the needed script.
+ $document = JFactory::getDocument();
+ $document->addScriptDeclaration(implode(' ',$script));
+ // return the button attached to input field.
+ return '' .$html . implode('',$button).'
';
+ }
+ }
+ return $html;
+ }
+
+ /**
+ * Method to get a list of options for a list input.
+ *
+ * @return array An array of JHtml options.
+ */
+ public function getOptions()
+ {
+ // get custom folder files
+ $localfolder = JPATH_COMPONENT_SITE.'/views';
+ // set the default
+ $options = array();
+ // import all needed classes
+ jimport('joomla.filesystem.folder');
+ // now check if there are files in the folder
+ if (JFolder::exists($localfolder) && $folders = JFolder::folders($localfolder))
+ {
+ foreach ($folders as $folder)
+ {
+ $options[] = JHtml::_('select.option', $folder, SermondistributorHelper::safeString($folder, 'W'));
+ }
+ }
+ return $options;
+ }
+}
diff --git a/admin/views/sermondistributor/tmpl/default_closed_issues_the_closed_issues_on_github.php b/admin/views/sermondistributor/tmpl/default_closed_issues_the_closed_issues_on_github.php
new file mode 100644
index 00000000..0bde8f9a
--- /dev/null
+++ b/admin/views/sermondistributor/tmpl/default_closed_issues_the_closed_issues_on_github.php
@@ -0,0 +1,30 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+?>
+github->closedissues; ?>
diff --git a/admin/views/sermondistributor/tmpl/default_open_issues_the_open_issues_on_github.php b/admin/views/sermondistributor/tmpl/default_open_issues_the_open_issues_on_github.php
new file mode 100644
index 00000000..1b033963
--- /dev/null
+++ b/admin/views/sermondistributor/tmpl/default_open_issues_the_open_issues_on_github.php
@@ -0,0 +1,30 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+?>
+github->openissues; ?>
diff --git a/admin/views/sermondistributor/tmpl/default_readme_information.php b/admin/views/sermondistributor/tmpl/default_readme_information.php
new file mode 100644
index 00000000..8a3b8e2a
--- /dev/null
+++ b/admin/views/sermondistributor/tmpl/default_readme_information.php
@@ -0,0 +1,30 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+?>
+readme; ?>
diff --git a/admin/views/sermondistributor/tmpl/default_vast_development_method_notice_board.php b/admin/views/sermondistributor/tmpl/default_vast_development_method_notice_board.php
new file mode 100644
index 00000000..39a3c379
--- /dev/null
+++ b/admin/views/sermondistributor/tmpl/default_vast_development_method_notice_board.php
@@ -0,0 +1,30 @@
+
+ @copyright Copyright (C) 2015. All Rights Reserved
+ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+
+ A sermon distributor that links to Dropbox.
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+// No direct access to this file
+defined('_JEXEC') or die('Restricted access');
+
+?>
+noticeboard; ?>
diff --git a/media/js/marked.js b/media/js/marked.js
new file mode 100644
index 00000000..0fdb1776
--- /dev/null
+++ b/media/js/marked.js
@@ -0,0 +1,7 @@
+/**
+ * marked - a markdown parser
+ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
+ * https://github.com/chjj/marked
+ */
+(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+=""+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return""+(escaped?code:escape(code,true))+"\n
"}return''+(escaped?code:escape(code,true))+"\n
\n"};Renderer.prototype.blockquote=function(quote){return"\n"+quote+"
\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+""+type+">\n"};Renderer.prototype.listitem=function(text){return""+text+"\n"};Renderer.prototype.paragraph=function(text){return""+text+"
\n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
\n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"
\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+""+type+">\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+"
"};Renderer.prototype.br=function(){return this.options.xhtml?"
":"
"};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='"+text+"";return out};Renderer.prototype.image=function(href,title,text){var out='":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:
"+escape(e.message+"",true)+"
"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}());
+