hexo.extend.tag.register('prompt', function(args, content){ args.unshift('prompt'); // make first argument args[1] not args[0] var name='user'; var dir=''; var symbol='$'; var prefix=''; var promptclass = 'promptuser'; if (args.length > 1) { name = args[1]; dir = args[2]+' '; symbol = args[3]; } if (typeof args[1] !=='undefined' && args[1].indexOf('root') >-1 || args[1]=='livecd') { promptclass = 'promptroot'; } if (args[2]=='0' || typeof args[2] == 'undefined') { dir = ''; } if (args[3]=='0' || typeof args[3] == 'undefined') { symbol = ''; } if (typeof args[4] !== 'undefined') { prefix = args[4] + ' '; }
var lines = content.split(/\r\n|\r|\n/).length+1 var gutter=''; var i=1; for (i=1; i<lines; i++) { gutter += prefix+"<span class='"+promptclass+"'>"+name+"</span> <span class='promptdir'>" + dir + symbol + "</span><br>" }
Creates justified brick wall of images with justifiedGallery.js.
Another js-library, magnificPopup.js, makes every image clickable and
opens a large version on the same page.
/** * jg tag by lisakov.com * * Examples jg * * {% jg img_path=https://lisakov.com/images/ thumbs_dir=800 thumbs_dir2=2000 lastonly=true %} * imagename1.jpg * imagename2.jpg "Title with description for imagename2" * {% endjg %} * * Arguments * * path: * path to images (img_path) * default: 'https://lisakov.com/images/' * * thumbs_dir: * path to thumbs (appended to img_path) * default: 'thumbs/' * none: no thumbs, use original images, useful for a single image * * thumbs_dir2: * path to medium thumbs (appended to img_path) * default: '800/' * if lastonly=true, last element gets * * lastonly: * <bool> (if true, use larger thumbs or original only for the last item) * default: false * use img_path + 'thumbs/' for every image except for the last, * last will be img_path + thumbs (equals to anything, if thumbs=undefined, use original) * */
hexo.extend.tag.register('jg', function(args, content){ // set defaults var img_path = 'https://lisakov.com/images/'; var thumbs_dir = 'thumbs/'; var thumbs_dir2 = '800/'; var lastonly = 'false'; // read arguments and replace defaults if needed args.forEach((el, idx) => { if (el.includes('img_path=')) { img_path = el.replace('img_path=',''); } if (el.includes('lastonly=')) { lastonly = el.replace('lastonly=',''); } if (el.includes('thumbs_dir=')) { thumbs_dir = el.replace('thumbs_dir=',''); thumbs_dir += thumbs_dir.endsWith("/") ? "" : "/"//add trailing slash if not present if (thumbs_dir.includes('none')) { thumbs_dir=''; } } if (el.includes('thumbs_dir2=')) { thumbs_dir2 = el.replace('thumbs_dir2=',''); thumbs_dir2 += thumbs_dir2.endsWith("/") ? "" : "/"//add trailing slash if not present if (thumbs_dir2.includes('none')) { thumbs_dir2 = ''; } } });
// Loop through all lines var lines = content.split(/\r\n|\r|\n/); lines.forEach((element, index, array) => { if (lastonly === 'false') { // if a line contains imgname but no title if (lines[index].indexOf('"') === -1) { lines[index] = '<a href=" ' + img_path + element + '"><img src="' + img_path + thumbs_dir + element + '"/></a>'; // if a line contains imgname and title } else { var title = lines[index].match(/"([^']+)"/)[1]; var img_name = lines[index].split(' ')[0]; lines[index] = '<a href=" ' + img_path + img_name + '"' + 'title="' + title + '"><img src="' + img_path + thumbs_dir + img_name + '"/></a>'; } // if lastonly=true } else {
// if it is the LAST element if (index === array.length - 1) { // if a line contains imgname but no title if (lines[index].indexOf('"') === -1) { lines[index] = '<a href=" ' + img_path + element + '"><img src="' + img_path + thumbs_dir2 + element + '"/></a>'; // if a line contains imgname and title } else { var title = lines[index].match(/"([^']+)"/)[1]; var img_name = lines[index].split(' ')[0]; lines[index] = '<a href=" ' + img_path + img_name + '"' + 'title="' + title + '"><img src="' + img_path + thumbs_dir2 + img_name + '"/></a>'; }
// if it is NOT the LAST element } else { // if a line contains imgname but no title if (lines[index].indexOf('"') === -1) { lines[index] = '<a href=" ' + img_path + element + '"><img src="' + img_path + thumbs_dir + element + '"/></a>'; // if a line contains imgname and title } else { var title = lines[index].match(/"([^']+)"/)[1]; var img_name = lines[index].split(' ')[0]; lines[index] = '<a href=" ' + img_path + img_name + '"' + 'title="' + title + '"><img src="' + img_path + thumbs_dir + img_name + '"/></a>'; } }