diff --git a/.github/workflows/daily_build.yml b/.github/workflows/daily_build.yml deleted file mode 100644 index f8d70f7..0000000 --- a/.github/workflows/daily_build.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Daily build - -on: - schedule: - - cron: "0 13 * * *" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Trigger build webhook on Netlify - run: curl -s -X POST "https://api.netlify.com/build_hooks/${TOKEN}" - env: - TOKEN: ${{ secrets.NETLIFY_CRON_BUILD_HOOK }} diff --git a/.github/workflows/deploy-to-neocities.yml b/.github/workflows/deploy-to-neocities.yml new file mode 100644 index 0000000..a03385c --- /dev/null +++ b/.github/workflows/deploy-to-neocities.yml @@ -0,0 +1,54 @@ +name: Deploy to neocities + +# only run on changes to main +on: + push: + branches: + - main + +concurrency: # prevent concurrent deploys doing strange things + group: deploy-to-neocities + cancel-in-progress: true + +# Default to bash +defaults: + run: + shell: bash + +jobs: + deploy: + runs-on: ubuntu-latest + env: + HUGO_VERSION: "0.121.1" + steps: + - name: Install Hugo CLI + run: | + wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ + && sudo dpkg -i ${{ runner.temp }}/hugo.deb + - name: Install Dart Sass + run: sudo snap install dart-sass + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Node.js dependencies + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + - name: Build with Hugo + env: + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo \ + --minify \ + --baseURL "https://runtimeterror.dev/" + - name: Highlight with Torchlight + run: | + npm i @torchlight-api/torchlight-cli + npx torchlight + - name: Deploy to neocities + uses: bcomnes/deploy-to-neocities@v1 + with: + api_token: ${{ secrets.NEOCITIES_API_TOKEN }} + cleanup: false + dist_dir: public \ No newline at end of file diff --git a/archetypes/default.md b/archetypes/default.md index f5d8663..f57f054 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -7,52 +7,32 @@ description: "This is a new post about..." featured: false toc: true comments: true -series: Tips # Projects, Code +categories: Tips # Backstage, ChromeOS, Code, Self-Hosting, VMware tags: - - 3dprinting - - activedirectory - android - - api - - automation - - availability - caddy - - certs - - chat - - chrome - chromeos - - cloud - - cluster - - containers - crostini - docker - gcp - homeassistant - - homelab - hugo - - iac - javascript - kubernetes - linux - - logs - meta - - networking - - openssl - packer - powercli - powershell - python - regex - - rest - salt - - security - selfhosting - - serverless - shell - tailscale - tasker - terraform - vmware - - vpn - windows - wireguard - wsl diff --git a/assets/js/back-to-top.js b/assets/js/back-to-top.js new file mode 100644 index 0000000..6be04a7 --- /dev/null +++ b/assets/js/back-to-top.js @@ -0,0 +1 @@ +"use strict";function addBackToTop(){var o,t,e,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.backgroundColor,d=void 0===r?"#000":r,a=i.cornerOffset,c=void 0===a?20:a,s=i.diameter,l=void 0===s?56:s,u=i.ease,p=void 0===u?function(o){return.5*(1-Math.cos(Math.PI*o))}:u,m=i.id,h=void 0===m?"back-to-top":m,b=i.innerHTML,v=void 0===b?'':b,f=i.onClickScrollTo,x=void 0===f?0:f,w=i.scrollContainer,g=void 0===w?document.body:w,k=i.scrollDuration,y=void 0===k?100:k,T=i.showWhenScrollTopIs,M=void 0===T?1:T,z=i.size,E=void 0===z?l:z,C=i.textColor,L=void 0===C?"#fff":C,N=i.zIndex,I=void 0===N?1:N,A=g===document.body,B=A&&document.documentElement;o=Math.round(.43*E),t=Math.round(.29*E),e="#"+h+"{background:"+d+";-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;bottom:"+c+"px;-webkit-box-shadow:0 2px 5px 0 rgba(0,0,0,.26);-moz-box-shadow:0 2px 5px 0 rgba(0,0,0,.26);box-shadow:0 2px 5px 0 rgba(0,0,0,.26);color:"+L+";cursor:pointer;display:block;height:"+E+"px;opacity:1;outline:0;position:fixed;right:"+c+"px;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-transition:bottom .2s,opacity .2s;-o-transition:bottom .2s,opacity .2s;-moz-transition:bottom .2s,opacity .2s;transition:bottom .2s,opacity .2s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:"+E+"px;z-index:"+I+"}#"+h+" svg{display:block;fill:currentColor;height:"+o+"px;margin:"+t+"px auto 0;width:"+o+"px}#"+h+".hidden{bottom:-"+E+"px;opacity:0}",(n=document.createElement("style")).appendChild(document.createTextNode(e)),document.head.insertAdjacentElement("afterbegin",n);var D=function(){var o=document.createElement("div");return o.id=h,o.className="hidden",o.innerHTML=v,o.addEventListener("click",function(o){o.preventDefault(),function(){var o="function"==typeof x?x():x,t=window,e=t.performance,n=t.requestAnimationFrame;if(y<=0||void 0===e||void 0===n)return q(o);var i=e.now(),r=j(),d=r-o;n(function o(t){var e=Math.min((t-i)/y,1);q(r-Math.round(p(e)*d)),e<1&&n(o)})}()}),document.body.appendChild(o),o}(),H=!0;function S(){j()>=M?function(){if(!H)return;D.className="",H=!1}():function(){if(H)return;D.className="hidden",H=!0}()}function j(){return g.scrollTop||B&&document.documentElement.scrollTop||0}function q(o){g.scrollTop=o,B&&(document.documentElement.scrollTop=o)}(A?window:g).addEventListener("scroll",S),S()} \ No newline at end of file diff --git a/assets/js/lunr.js b/assets/js/lunr.js new file mode 100644 index 0000000..7118d74 --- /dev/null +++ b/assets/js/lunr.js @@ -0,0 +1,3475 @@ +/** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.9 + * Copyright (C) 2020 Oliver Nightingale + * @license MIT + */ + +;(function(){ + + /** + * A convenience function for configuring and constructing + * a new lunr Index. + * + * A lunr.Builder instance is created and the pipeline setup + * with a trimmer, stop word filter and stemmer. + * + * This builder object is yielded to the configuration function + * that is passed as a parameter, allowing the list of fields + * and other builder parameters to be customised. + * + * All documents _must_ be added within the passed config function. + * + * @example + * var idx = lunr(function () { + * this.field('title') + * this.field('body') + * this.ref('id') + * + * documents.forEach(function (doc) { + * this.add(doc) + * }, this) + * }) + * + * @see {@link lunr.Builder} + * @see {@link lunr.Pipeline} + * @see {@link lunr.trimmer} + * @see {@link lunr.stopWordFilter} + * @see {@link lunr.stemmer} + * @namespace {function} lunr + */ + var lunr = function (config) { + var builder = new lunr.Builder + + builder.pipeline.add( + lunr.trimmer, + lunr.stopWordFilter, + lunr.stemmer + ) + + builder.searchPipeline.add( + lunr.stemmer + ) + + config.call(builder, builder) + return builder.build() + } + + lunr.version = "2.3.9" + /*! + * lunr.utils + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * A namespace containing utils for the rest of the lunr library + * @namespace lunr.utils + */ + lunr.utils = {} + + /** + * Print a warning message to the console. + * + * @param {String} message The message to be printed. + * @memberOf lunr.utils + * @function + */ + lunr.utils.warn = (function (global) { + /* eslint-disable no-console */ + return function (message) { + if (global.console && console.warn) { + console.warn(message) + } + } + /* eslint-enable no-console */ + })(this) + + /** + * Convert an object to a string. + * + * In the case of `null` and `undefined` the function returns + * the empty string, in all other cases the result of calling + * `toString` on the passed object is returned. + * + * @param {Any} obj The object to convert to a string. + * @return {String} string representation of the passed object. + * @memberOf lunr.utils + */ + lunr.utils.asString = function (obj) { + if (obj === void 0 || obj === null) { + return "" + } else { + return obj.toString() + } + } + + /** + * Clones an object. + * + * Will create a copy of an existing object such that any mutations + * on the copy cannot affect the original. + * + * Only shallow objects are supported, passing a nested object to this + * function will cause a TypeError. + * + * Objects with primitives, and arrays of primitives are supported. + * + * @param {Object} obj The object to clone. + * @return {Object} a clone of the passed object. + * @throws {TypeError} when a nested object is passed. + * @memberOf Utils + */ + lunr.utils.clone = function (obj) { + if (obj === null || obj === undefined) { + return obj + } + + var clone = Object.create(null), + keys = Object.keys(obj) + + for (var i = 0; i < keys.length; i++) { + var key = keys[i], + val = obj[key] + + if (Array.isArray(val)) { + clone[key] = val.slice() + continue + } + + if (typeof val === 'string' || + typeof val === 'number' || + typeof val === 'boolean') { + clone[key] = val + continue + } + + throw new TypeError("clone is not deep and does not support nested objects") + } + + return clone + } + lunr.FieldRef = function (docRef, fieldName, stringValue) { + this.docRef = docRef + this.fieldName = fieldName + this._stringValue = stringValue + } + + lunr.FieldRef.joiner = "/" + + lunr.FieldRef.fromString = function (s) { + var n = s.indexOf(lunr.FieldRef.joiner) + + if (n === -1) { + throw "malformed field ref string" + } + + var fieldRef = s.slice(0, n), + docRef = s.slice(n + 1) + + return new lunr.FieldRef (docRef, fieldRef, s) + } + + lunr.FieldRef.prototype.toString = function () { + if (this._stringValue == undefined) { + this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef + } + + return this._stringValue + } + /*! + * lunr.Set + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * A lunr set. + * + * @constructor + */ + lunr.Set = function (elements) { + this.elements = Object.create(null) + + if (elements) { + this.length = elements.length + + for (var i = 0; i < this.length; i++) { + this.elements[elements[i]] = true + } + } else { + this.length = 0 + } + } + + /** + * A complete set that contains all elements. + * + * @static + * @readonly + * @type {lunr.Set} + */ + lunr.Set.complete = { + intersect: function (other) { + return other + }, + + union: function () { + return this + }, + + contains: function () { + return true + } + } + + /** + * An empty set that contains no elements. + * + * @static + * @readonly + * @type {lunr.Set} + */ + lunr.Set.empty = { + intersect: function () { + return this + }, + + union: function (other) { + return other + }, + + contains: function () { + return false + } + } + + /** + * Returns true if this set contains the specified object. + * + * @param {object} object - Object whose presence in this set is to be tested. + * @returns {boolean} - True if this set contains the specified object. + */ + lunr.Set.prototype.contains = function (object) { + return !!this.elements[object] + } + + /** + * Returns a new set containing only the elements that are present in both + * this set and the specified set. + * + * @param {lunr.Set} other - set to intersect with this set. + * @returns {lunr.Set} a new set that is the intersection of this and the specified set. + */ + + lunr.Set.prototype.intersect = function (other) { + var a, b, elements, intersection = [] + + if (other === lunr.Set.complete) { + return this + } + + if (other === lunr.Set.empty) { + return other + } + + if (this.length < other.length) { + a = this + b = other + } else { + a = other + b = this + } + + elements = Object.keys(a.elements) + + for (var i = 0; i < elements.length; i++) { + var element = elements[i] + if (element in b.elements) { + intersection.push(element) + } + } + + return new lunr.Set (intersection) + } + + /** + * Returns a new set combining the elements of this and the specified set. + * + * @param {lunr.Set} other - set to union with this set. + * @return {lunr.Set} a new set that is the union of this and the specified set. + */ + + lunr.Set.prototype.union = function (other) { + if (other === lunr.Set.complete) { + return lunr.Set.complete + } + + if (other === lunr.Set.empty) { + return this + } + + return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements))) + } + /** + * A function to calculate the inverse document frequency for + * a posting. This is shared between the builder and the index + * + * @private + * @param {object} posting - The posting for a given term + * @param {number} documentCount - The total number of documents. + */ + lunr.idf = function (posting, documentCount) { + var documentsWithTerm = 0 + + for (var fieldName in posting) { + if (fieldName == '_index') continue // Ignore the term index, its not a field + documentsWithTerm += Object.keys(posting[fieldName]).length + } + + var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5) + + return Math.log(1 + Math.abs(x)) + } + + /** + * A token wraps a string representation of a token + * as it is passed through the text processing pipeline. + * + * @constructor + * @param {string} [str=''] - The string token being wrapped. + * @param {object} [metadata={}] - Metadata associated with this token. + */ + lunr.Token = function (str, metadata) { + this.str = str || "" + this.metadata = metadata || {} + } + + /** + * Returns the token string that is being wrapped by this object. + * + * @returns {string} + */ + lunr.Token.prototype.toString = function () { + return this.str + } + + /** + * A token update function is used when updating or optionally + * when cloning a token. + * + * @callback lunr.Token~updateFunction + * @param {string} str - The string representation of the token. + * @param {Object} metadata - All metadata associated with this token. + */ + + /** + * Applies the given function to the wrapped string token. + * + * @example + * token.update(function (str, metadata) { + * return str.toUpperCase() + * }) + * + * @param {lunr.Token~updateFunction} fn - A function to apply to the token string. + * @returns {lunr.Token} + */ + lunr.Token.prototype.update = function (fn) { + this.str = fn(this.str, this.metadata) + return this + } + + /** + * Creates a clone of this token. Optionally a function can be + * applied to the cloned token. + * + * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token. + * @returns {lunr.Token} + */ + lunr.Token.prototype.clone = function (fn) { + fn = fn || function (s) { return s } + return new lunr.Token (fn(this.str, this.metadata), this.metadata) + } + /*! + * lunr.tokenizer + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * A function for splitting a string into tokens ready to be inserted into + * the search index. Uses `lunr.tokenizer.separator` to split strings, change + * the value of this property to change how strings are split into tokens. + * + * This tokenizer will convert its parameter to a string by calling `toString` and + * then will split this string on the character in `lunr.tokenizer.separator`. + * Arrays will have their elements converted to strings and wrapped in a lunr.Token. + * + * Optional metadata can be passed to the tokenizer, this metadata will be cloned and + * added as metadata to every token that is created from the object to be tokenized. + * + * @static + * @param {?(string|object|object[])} obj - The object to convert into tokens + * @param {?object} metadata - Optional metadata to associate with every token + * @returns {lunr.Token[]} + * @see {@link lunr.Pipeline} + */ + lunr.tokenizer = function (obj, metadata) { + if (obj == null || obj == undefined) { + return [] + } + + if (Array.isArray(obj)) { + return obj.map(function (t) { + return new lunr.Token( + lunr.utils.asString(t).toLowerCase(), + lunr.utils.clone(metadata) + ) + }) + } + + var str = obj.toString().toLowerCase(), + len = str.length, + tokens = [] + + for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) { + var char = str.charAt(sliceEnd), + sliceLength = sliceEnd - sliceStart + + if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) { + + if (sliceLength > 0) { + var tokenMetadata = lunr.utils.clone(metadata) || {} + tokenMetadata["position"] = [sliceStart, sliceLength] + tokenMetadata["index"] = tokens.length + + tokens.push( + new lunr.Token ( + str.slice(sliceStart, sliceEnd), + tokenMetadata + ) + ) + } + + sliceStart = sliceEnd + 1 + } + + } + + return tokens + } + + /** + * The separator used to split a string into tokens. Override this property to change the behaviour of + * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens. + * + * @static + * @see lunr.tokenizer + */ + lunr.tokenizer.separator = /[\s\-]+/ + /*! + * lunr.Pipeline + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * lunr.Pipelines maintain an ordered list of functions to be applied to all + * tokens in documents entering the search index and queries being ran against + * the index. + * + * An instance of lunr.Index created with the lunr shortcut will contain a + * pipeline with a stop word filter and an English language stemmer. Extra + * functions can be added before or after either of these functions or these + * default functions can be removed. + * + * When run the pipeline will call each function in turn, passing a token, the + * index of that token in the original list of all tokens and finally a list of + * all the original tokens. + * + * The output of functions in the pipeline will be passed to the next function + * in the pipeline. To exclude a token from entering the index the function + * should return undefined, the rest of the pipeline will not be called with + * this token. + * + * For serialisation of pipelines to work, all functions used in an instance of + * a pipeline should be registered with lunr.Pipeline. Registered functions can + * then be loaded. If trying to load a serialised pipeline that uses functions + * that are not registered an error will be thrown. + * + * If not planning on serialising the pipeline then registering pipeline functions + * is not necessary. + * + * @constructor + */ + lunr.Pipeline = function () { + this._stack = [] + } + + lunr.Pipeline.registeredFunctions = Object.create(null) + + /** + * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token + * string as well as all known metadata. A pipeline function can mutate the token string + * or mutate (or add) metadata for a given token. + * + * A pipeline function can indicate that the passed token should be discarded by returning + * null, undefined or an empty string. This token will not be passed to any downstream pipeline + * functions and will not be added to the index. + * + * Multiple tokens can be returned by returning an array of tokens. Each token will be passed + * to any downstream pipeline functions and all will returned tokens will be added to the index. + * + * Any number of pipeline functions may be chained together using a lunr.Pipeline. + * + * @interface lunr.PipelineFunction + * @param {lunr.Token} token - A token from the document being processed. + * @param {number} i - The index of this token in the complete list of tokens for this document/field. + * @param {lunr.Token[]} tokens - All tokens for this document/field. + * @returns {(?lunr.Token|lunr.Token[])} + */ + + /** + * Register a function with the pipeline. + * + * Functions that are used in the pipeline should be registered if the pipeline + * needs to be serialised, or a serialised pipeline needs to be loaded. + * + * Registering a function does not add it to a pipeline, functions must still be + * added to instances of the pipeline for them to be used when running a pipeline. + * + * @param {lunr.PipelineFunction} fn - The function to check for. + * @param {String} label - The label to register this function with + */ + lunr.Pipeline.registerFunction = function (fn, label) { + if (label in this.registeredFunctions) { + lunr.utils.warn('Overwriting existing registered function: ' + label) + } + + fn.label = label + lunr.Pipeline.registeredFunctions[fn.label] = fn + } + + /** + * Warns if the function is not registered as a Pipeline function. + * + * @param {lunr.PipelineFunction} fn - The function to check for. + * @private + */ + lunr.Pipeline.warnIfFunctionNotRegistered = function (fn) { + var isRegistered = fn.label && (fn.label in this.registeredFunctions) + + if (!isRegistered) { + lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\n', fn) + } + } + + /** + * Loads a previously serialised pipeline. + * + * All functions to be loaded must already be registered with lunr.Pipeline. + * If any function from the serialised data has not been registered then an + * error will be thrown. + * + * @param {Object} serialised - The serialised pipeline to load. + * @returns {lunr.Pipeline} + */ + lunr.Pipeline.load = function (serialised) { + var pipeline = new lunr.Pipeline + + serialised.forEach(function (fnName) { + var fn = lunr.Pipeline.registeredFunctions[fnName] + + if (fn) { + pipeline.add(fn) + } else { + throw new Error('Cannot load unregistered function: ' + fnName) + } + }) + + return pipeline + } + + /** + * Adds new functions to the end of the pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline. + */ + lunr.Pipeline.prototype.add = function () { + var fns = Array.prototype.slice.call(arguments) + + fns.forEach(function (fn) { + lunr.Pipeline.warnIfFunctionNotRegistered(fn) + this._stack.push(fn) + }, this) + } + + /** + * Adds a single function after a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline. + * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline. + */ + lunr.Pipeline.prototype.after = function (existingFn, newFn) { + lunr.Pipeline.warnIfFunctionNotRegistered(newFn) + + var pos = this._stack.indexOf(existingFn) + if (pos == -1) { + throw new Error('Cannot find existingFn') + } + + pos = pos + 1 + this._stack.splice(pos, 0, newFn) + } + + /** + * Adds a single function before a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline. + * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline. + */ + lunr.Pipeline.prototype.before = function (existingFn, newFn) { + lunr.Pipeline.warnIfFunctionNotRegistered(newFn) + + var pos = this._stack.indexOf(existingFn) + if (pos == -1) { + throw new Error('Cannot find existingFn') + } + + this._stack.splice(pos, 0, newFn) + } + + /** + * Removes a function from the pipeline. + * + * @param {lunr.PipelineFunction} fn The function to remove from the pipeline. + */ + lunr.Pipeline.prototype.remove = function (fn) { + var pos = this._stack.indexOf(fn) + if (pos == -1) { + return + } + + this._stack.splice(pos, 1) + } + + /** + * Runs the current list of functions that make up the pipeline against the + * passed tokens. + * + * @param {Array} tokens The tokens to run through the pipeline. + * @returns {Array} + */ + lunr.Pipeline.prototype.run = function (tokens) { + var stackLength = this._stack.length + + for (var i = 0; i < stackLength; i++) { + var fn = this._stack[i] + var memo = [] + + for (var j = 0; j < tokens.length; j++) { + var result = fn(tokens[j], j, tokens) + + if (result === null || result === void 0 || result === '') continue + + if (Array.isArray(result)) { + for (var k = 0; k < result.length; k++) { + memo.push(result[k]) + } + } else { + memo.push(result) + } + } + + tokens = memo + } + + return tokens + } + + /** + * Convenience method for passing a string through a pipeline and getting + * strings out. This method takes care of wrapping the passed string in a + * token and mapping the resulting tokens back to strings. + * + * @param {string} str - The string to pass through the pipeline. + * @param {?object} metadata - Optional metadata to associate with the token + * passed to the pipeline. + * @returns {string[]} + */ + lunr.Pipeline.prototype.runString = function (str, metadata) { + var token = new lunr.Token (str, metadata) + + return this.run([token]).map(function (t) { + return t.toString() + }) + } + + /** + * Resets the pipeline by removing any existing processors. + * + */ + lunr.Pipeline.prototype.reset = function () { + this._stack = [] + } + + /** + * Returns a representation of the pipeline ready for serialisation. + * + * Logs a warning if the function has not been registered. + * + * @returns {Array} + */ + lunr.Pipeline.prototype.toJSON = function () { + return this._stack.map(function (fn) { + lunr.Pipeline.warnIfFunctionNotRegistered(fn) + + return fn.label + }) + } + /*! + * lunr.Vector + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * A vector is used to construct the vector space of documents and queries. These + * vectors support operations to determine the similarity between two documents or + * a document and a query. + * + * Normally no parameters are required for initializing a vector, but in the case of + * loading a previously dumped vector the raw elements can be provided to the constructor. + * + * For performance reasons vectors are implemented with a flat array, where an elements + * index is immediately followed by its value. E.g. [index, value, index, value]. This + * allows the underlying array to be as sparse as possible and still offer decent + * performance when being used for vector calculations. + * + * @constructor + * @param {Number[]} [elements] - The flat list of element index and element value pairs. + */ + lunr.Vector = function (elements) { + this._magnitude = 0 + this.elements = elements || [] + } + + + /** + * Calculates the position within the vector to insert a given index. + * + * This is used internally by insert and upsert. If there are duplicate indexes then + * the position is returned as if the value for that index were to be updated, but it + * is the callers responsibility to check whether there is a duplicate at that index + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @returns {Number} + */ + lunr.Vector.prototype.positionForIndex = function (index) { + // For an empty vector the tuple can be inserted at the beginning + if (this.elements.length == 0) { + return 0 + } + + var start = 0, + end = this.elements.length / 2, + sliceLength = end - start, + pivotPoint = Math.floor(sliceLength / 2), + pivotIndex = this.elements[pivotPoint * 2] + + while (sliceLength > 1) { + if (pivotIndex < index) { + start = pivotPoint + } + + if (pivotIndex > index) { + end = pivotPoint + } + + if (pivotIndex == index) { + break + } + + sliceLength = end - start + pivotPoint = start + Math.floor(sliceLength / 2) + pivotIndex = this.elements[pivotPoint * 2] + } + + if (pivotIndex == index) { + return pivotPoint * 2 + } + + if (pivotIndex > index) { + return pivotPoint * 2 + } + + if (pivotIndex < index) { + return (pivotPoint + 1) * 2 + } + } + + /** + * Inserts an element at an index within the vector. + * + * Does not allow duplicates, will throw an error if there is already an entry + * for this index. + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @param {Number} val - The value to be inserted into the vector. + */ + lunr.Vector.prototype.insert = function (insertIdx, val) { + this.upsert(insertIdx, val, function () { + throw "duplicate index" + }) + } + + /** + * Inserts or updates an existing index within the vector. + * + * @param {Number} insertIdx - The index at which the element should be inserted. + * @param {Number} val - The value to be inserted into the vector. + * @param {function} fn - A function that is called for updates, the existing value and the + * requested value are passed as arguments + */ + lunr.Vector.prototype.upsert = function (insertIdx, val, fn) { + this._magnitude = 0 + var position = this.positionForIndex(insertIdx) + + if (this.elements[position] == insertIdx) { + this.elements[position + 1] = fn(this.elements[position + 1], val) + } else { + this.elements.splice(position, 0, insertIdx, val) + } + } + + /** + * Calculates the magnitude of this vector. + * + * @returns {Number} + */ + lunr.Vector.prototype.magnitude = function () { + if (this._magnitude) return this._magnitude + + var sumOfSquares = 0, + elementsLength = this.elements.length + + for (var i = 1; i < elementsLength; i += 2) { + var val = this.elements[i] + sumOfSquares += val * val + } + + return this._magnitude = Math.sqrt(sumOfSquares) + } + + /** + * Calculates the dot product of this vector and another vector. + * + * @param {lunr.Vector} otherVector - The vector to compute the dot product with. + * @returns {Number} + */ + lunr.Vector.prototype.dot = function (otherVector) { + var dotProduct = 0, + a = this.elements, b = otherVector.elements, + aLen = a.length, bLen = b.length, + aVal = 0, bVal = 0, + i = 0, j = 0 + + while (i < aLen && j < bLen) { + aVal = a[i], bVal = b[j] + if (aVal < bVal) { + i += 2 + } else if (aVal > bVal) { + j += 2 + } else if (aVal == bVal) { + dotProduct += a[i + 1] * b[j + 1] + i += 2 + j += 2 + } + } + + return dotProduct + } + + /** + * Calculates the similarity between this vector and another vector. + * + * @param {lunr.Vector} otherVector - The other vector to calculate the + * similarity with. + * @returns {Number} + */ + lunr.Vector.prototype.similarity = function (otherVector) { + return this.dot(otherVector) / this.magnitude() || 0 + } + + /** + * Converts the vector to an array of the elements within the vector. + * + * @returns {Number[]} + */ + lunr.Vector.prototype.toArray = function () { + var output = new Array (this.elements.length / 2) + + for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) { + output[j] = this.elements[i] + } + + return output + } + + /** + * A JSON serializable representation of the vector. + * + * @returns {Number[]} + */ + lunr.Vector.prototype.toJSON = function () { + return this.elements + } + /* eslint-disable */ + /*! + * lunr.stemmer + * Copyright (C) 2020 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ + + /** + * lunr.stemmer is an english language stemmer, this is a JavaScript + * implementation of the PorterStemmer taken from http://tartarus.org/~martin + * + * @static + * @implements {lunr.PipelineFunction} + * @param {lunr.Token} token - The string to stem + * @returns {lunr.Token} + * @see {@link lunr.Pipeline} + * @function + */ + lunr.stemmer = (function(){ + var step2list = { + "ational" : "ate", + "tional" : "tion", + "enci" : "ence", + "anci" : "ance", + "izer" : "ize", + "bli" : "ble", + "alli" : "al", + "entli" : "ent", + "eli" : "e", + "ousli" : "ous", + "ization" : "ize", + "ation" : "ate", + "ator" : "ate", + "alism" : "al", + "iveness" : "ive", + "fulness" : "ful", + "ousness" : "ous", + "aliti" : "al", + "iviti" : "ive", + "biliti" : "ble", + "logi" : "log" + }, + + step3list = { + "icate" : "ic", + "ative" : "", + "alize" : "al", + "iciti" : "ic", + "ical" : "ic", + "ful" : "", + "ness" : "" + }, + + c = "[^aeiou]", // consonant + v = "[aeiouy]", // vowel + C = c + "[^aeiouy]*", // consonant sequence + V = v + "[aeiou]*", // vowel sequence + + mgr0 = "^(" + C + ")?" + V + C, // [C]VC... is m>0 + meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$", // [C]VC[V] is m=1 + mgr1 = "^(" + C + ")?" + V + C + V + C, // [C]VCVC... is m>1 + s_v = "^(" + C + ")?" + v; // vowel in stem + + var re_mgr0 = new RegExp(mgr0); + var re_mgr1 = new RegExp(mgr1); + var re_meq1 = new RegExp(meq1); + var re_s_v = new RegExp(s_v); + + var re_1a = /^(.+?)(ss|i)es$/; + var re2_1a = /^(.+?)([^s])s$/; + var re_1b = /^(.+?)eed$/; + var re2_1b = /^(.+?)(ed|ing)$/; + var re_1b_2 = /.$/; + var re2_1b_2 = /(at|bl|iz)$/; + var re3_1b_2 = new RegExp("([^aeiouylsz])\\1$"); + var re4_1b_2 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + + var re_1c = /^(.+?[^aeiou])y$/; + var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + + var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + + var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + var re2_4 = /^(.+?)(s|t)(ion)$/; + + var re_5 = /^(.+?)e$/; + var re_5_1 = /ll$/; + var re3_5 = new RegExp("^" + C + v + "[^aeiouwxy]$"); + + var porterStemmer = function porterStemmer(w) { + var stem, + suffix, + firstch, + re, + re2, + re3, + re4; + + if (w.length < 3) { return w; } + + firstch = w.substr(0,1); + if (firstch == "y") { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = re_1a + re2 = re2_1a; + + if (re.test(w)) { w = w.replace(re,"$1$2"); } + else if (re2.test(w)) { w = w.replace(re2,"$1$2"); } + + // Step 1b + re = re_1b; + re2 = re2_1b; + if (re.test(w)) { + var fp = re.exec(w); + re = re_mgr0; + if (re.test(fp[1])) { + re = re_1b_2; + w = w.replace(re,""); + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = re_s_v; + if (re2.test(stem)) { + w = stem; + re2 = re2_1b_2; + re3 = re3_1b_2; + re4 = re4_1b_2; + if (re2.test(w)) { w = w + "e"; } + else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,""); } + else if (re4.test(w)) { w = w + "e"; } + } + } + + // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say) + re = re_1c; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + w = stem + "i"; + } + + // Step 2 + re = re_2; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = re_3; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = re_4; + re2 = re2_4; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + if (re.test(stem)) { + w = stem; + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = re_mgr1; + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = re_5; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + re2 = re_meq1; + re3 = re3_5; + if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) { + w = stem; + } + } + + re = re_5_1; + re2 = re_mgr1; + if (re.test(w) && re2.test(w)) { + re = re_1b_2; + w = w.replace(re,""); + } + + // and turn initial Y back to y + + if (firstch == "y") { + w = firstch.toLowerCase() + w.substr(1); + } + + return w; + }; + + return function (token) { + return token.update(porterStemmer); + } + })(); + + lunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer') + /*! + * lunr.stopWordFilter + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * lunr.generateStopWordFilter builds a stopWordFilter function from the provided + * list of stop words. + * + * The built in lunr.stopWordFilter is built using this generator and can be used + * to generate custom stopWordFilters for applications or non English languages. + * + * @function + * @param {Array} token The token to pass through the filter + * @returns {lunr.PipelineFunction} + * @see lunr.Pipeline + * @see lunr.stopWordFilter + */ + lunr.generateStopWordFilter = function (stopWords) { + var words = stopWords.reduce(function (memo, stopWord) { + memo[stopWord] = stopWord + return memo + }, {}) + + return function (token) { + if (token && words[token.toString()] !== token.toString()) return token + } + } + + /** + * lunr.stopWordFilter is an English language stop word list filter, any words + * contained in the list will not be passed through the filter. + * + * This is intended to be used in the Pipeline. If the token does not pass the + * filter then undefined will be returned. + * + * @function + * @implements {lunr.PipelineFunction} + * @params {lunr.Token} token - A token to check for being a stop word. + * @returns {lunr.Token} + * @see {@link lunr.Pipeline} + */ + lunr.stopWordFilter = lunr.generateStopWordFilter([ + 'a', + 'able', + 'about', + 'across', + 'after', + 'all', + 'almost', + 'also', + 'am', + 'among', + 'an', + 'and', + 'any', + 'are', + 'as', + 'at', + 'be', + 'because', + 'been', + 'but', + 'by', + 'can', + 'cannot', + 'could', + 'dear', + 'did', + 'do', + 'does', + 'either', + 'else', + 'ever', + 'every', + 'for', + 'from', + 'get', + 'got', + 'had', + 'has', + 'have', + 'he', + 'her', + 'hers', + 'him', + 'his', + 'how', + 'however', + 'i', + 'if', + 'in', + 'into', + 'is', + 'it', + 'its', + 'just', + 'least', + 'let', + 'like', + 'likely', + 'may', + 'me', + 'might', + 'most', + 'must', + 'my', + 'neither', + 'no', + 'nor', + 'not', + 'of', + 'off', + 'often', + 'on', + 'only', + 'or', + 'other', + 'our', + 'own', + 'rather', + 'said', + 'say', + 'says', + 'she', + 'should', + 'since', + 'so', + 'some', + 'than', + 'that', + 'the', + 'their', + 'them', + 'then', + 'there', + 'these', + 'they', + 'this', + 'tis', + 'to', + 'too', + 'twas', + 'us', + 'wants', + 'was', + 'we', + 'were', + 'what', + 'when', + 'where', + 'which', + 'while', + 'who', + 'whom', + 'why', + 'will', + 'with', + 'would', + 'yet', + 'you', + 'your' + ]) + + lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter') + /*! + * lunr.trimmer + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * lunr.trimmer is a pipeline function for trimming non word + * characters from the beginning and end of tokens before they + * enter the index. + * + * This implementation may not work correctly for non latin + * characters and should either be removed or adapted for use + * with languages with non-latin characters. + * + * @static + * @implements {lunr.PipelineFunction} + * @param {lunr.Token} token The token to pass through the filter + * @returns {lunr.Token} + * @see lunr.Pipeline + */ + lunr.trimmer = function (token) { + return token.update(function (s) { + return s.replace(/^\W+/, '').replace(/\W+$/, '') + }) + } + + lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer') + /*! + * lunr.TokenSet + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * A token set is used to store the unique list of all tokens + * within an index. Token sets are also used to represent an + * incoming query to the index, this query token set and index + * token set are then intersected to find which tokens to look + * up in the inverted index. + * + * A token set can hold multiple tokens, as in the case of the + * index token set, or it can hold a single token as in the + * case of a simple query token set. + * + * Additionally token sets are used to perform wildcard matching. + * Leading, contained and trailing wildcards are supported, and + * from this edit distance matching can also be provided. + * + * Token sets are implemented as a minimal finite state automata, + * where both common prefixes and suffixes are shared between tokens. + * This helps to reduce the space used for storing the token set. + * + * @constructor + */ + lunr.TokenSet = function () { + this.final = false + this.edges = {} + this.id = lunr.TokenSet._nextId + lunr.TokenSet._nextId += 1 + } + + /** + * Keeps track of the next, auto increment, identifier to assign + * to a new tokenSet. + * + * TokenSets require a unique identifier to be correctly minimised. + * + * @private + */ + lunr.TokenSet._nextId = 1 + + /** + * Creates a TokenSet instance from the given sorted array of words. + * + * @param {String[]} arr - A sorted array of strings to create the set from. + * @returns {lunr.TokenSet} + * @throws Will throw an error if the input array is not sorted. + */ + lunr.TokenSet.fromArray = function (arr) { + var builder = new lunr.TokenSet.Builder + + for (var i = 0, len = arr.length; i < len; i++) { + builder.insert(arr[i]) + } + + builder.finish() + return builder.root + } + + /** + * Creates a token set from a query clause. + * + * @private + * @param {Object} clause - A single clause from lunr.Query. + * @param {string} clause.term - The query clause term. + * @param {number} [clause.editDistance] - The optional edit distance for the term. + * @returns {lunr.TokenSet} + */ + lunr.TokenSet.fromClause = function (clause) { + if ('editDistance' in clause) { + return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance) + } else { + return lunr.TokenSet.fromString(clause.term) + } + } + + /** + * Creates a token set representing a single string with a specified + * edit distance. + * + * Insertions, deletions, substitutions and transpositions are each + * treated as an edit distance of 1. + * + * Increasing the allowed edit distance will have a dramatic impact + * on the performance of both creating and intersecting these TokenSets. + * It is advised to keep the edit distance less than 3. + * + * @param {string} str - The string to create the token set from. + * @param {number} editDistance - The allowed edit distance to match. + * @returns {lunr.Vector} + */ + lunr.TokenSet.fromFuzzyString = function (str, editDistance) { + var root = new lunr.TokenSet + + var stack = [{ + node: root, + editsRemaining: editDistance, + str: str + }] + + while (stack.length) { + var frame = stack.pop() + + // no edit + if (frame.str.length > 0) { + var char = frame.str.charAt(0), + noEditNode + + if (char in frame.node.edges) { + noEditNode = frame.node.edges[char] + } else { + noEditNode = new lunr.TokenSet + frame.node.edges[char] = noEditNode + } + + if (frame.str.length == 1) { + noEditNode.final = true + } + + stack.push({ + node: noEditNode, + editsRemaining: frame.editsRemaining, + str: frame.str.slice(1) + }) + } + + if (frame.editsRemaining == 0) { + continue + } + + // insertion + if ("*" in frame.node.edges) { + var insertionNode = frame.node.edges["*"] + } else { + var insertionNode = new lunr.TokenSet + frame.node.edges["*"] = insertionNode + } + + if (frame.str.length == 0) { + insertionNode.final = true + } + + stack.push({ + node: insertionNode, + editsRemaining: frame.editsRemaining - 1, + str: frame.str + }) + + // deletion + // can only do a deletion if we have enough edits remaining + // and if there are characters left to delete in the string + if (frame.str.length > 1) { + stack.push({ + node: frame.node, + editsRemaining: frame.editsRemaining - 1, + str: frame.str.slice(1) + }) + } + + // deletion + // just removing the last character from the str + if (frame.str.length == 1) { + frame.node.final = true + } + + // substitution + // can only do a substitution if we have enough edits remaining + // and if there are characters left to substitute + if (frame.str.length >= 1) { + if ("*" in frame.node.edges) { + var substitutionNode = frame.node.edges["*"] + } else { + var substitutionNode = new lunr.TokenSet + frame.node.edges["*"] = substitutionNode + } + + if (frame.str.length == 1) { + substitutionNode.final = true + } + + stack.push({ + node: substitutionNode, + editsRemaining: frame.editsRemaining - 1, + str: frame.str.slice(1) + }) + } + + // transposition + // can only do a transposition if there are edits remaining + // and there are enough characters to transpose + if (frame.str.length > 1) { + var charA = frame.str.charAt(0), + charB = frame.str.charAt(1), + transposeNode + + if (charB in frame.node.edges) { + transposeNode = frame.node.edges[charB] + } else { + transposeNode = new lunr.TokenSet + frame.node.edges[charB] = transposeNode + } + + if (frame.str.length == 1) { + transposeNode.final = true + } + + stack.push({ + node: transposeNode, + editsRemaining: frame.editsRemaining - 1, + str: charA + frame.str.slice(2) + }) + } + } + + return root + } + + /** + * Creates a TokenSet from a string. + * + * The string may contain one or more wildcard characters (*) + * that will allow wildcard matching when intersecting with + * another TokenSet. + * + * @param {string} str - The string to create a TokenSet from. + * @returns {lunr.TokenSet} + */ + lunr.TokenSet.fromString = function (str) { + var node = new lunr.TokenSet, + root = node + + /* + * Iterates through all characters within the passed string + * appending a node for each character. + * + * When a wildcard character is found then a self + * referencing edge is introduced to continually match + * any number of any characters. + */ + for (var i = 0, len = str.length; i < len; i++) { + var char = str[i], + final = (i == len - 1) + + if (char == "*") { + node.edges[char] = node + node.final = final + + } else { + var next = new lunr.TokenSet + next.final = final + + node.edges[char] = next + node = next + } + } + + return root + } + + /** + * Converts this TokenSet into an array of strings + * contained within the TokenSet. + * + * This is not intended to be used on a TokenSet that + * contains wildcards, in these cases the results are + * undefined and are likely to cause an infinite loop. + * + * @returns {string[]} + */ + lunr.TokenSet.prototype.toArray = function () { + var words = [] + + var stack = [{ + prefix: "", + node: this + }] + + while (stack.length) { + var frame = stack.pop(), + edges = Object.keys(frame.node.edges), + len = edges.length + + if (frame.node.final) { + /* In Safari, at this point the prefix is sometimes corrupted, see: + * https://github.com/olivernn/lunr.js/issues/279 Calling any + * String.prototype method forces Safari to "cast" this string to what + * it's supposed to be, fixing the bug. */ + frame.prefix.charAt(0) + words.push(frame.prefix) + } + + for (var i = 0; i < len; i++) { + var edge = edges[i] + + stack.push({ + prefix: frame.prefix.concat(edge), + node: frame.node.edges[edge] + }) + } + } + + return words + } + + /** + * Generates a string representation of a TokenSet. + * + * This is intended to allow TokenSets to be used as keys + * in objects, largely to aid the construction and minimisation + * of a TokenSet. As such it is not designed to be a human + * friendly representation of the TokenSet. + * + * @returns {string} + */ + lunr.TokenSet.prototype.toString = function () { + // NOTE: Using Object.keys here as this.edges is very likely + // to enter 'hash-mode' with many keys being added + // + // avoiding a for-in loop here as it leads to the function + // being de-optimised (at least in V8). From some simple + // benchmarks the performance is comparable, but allowing + // V8 to optimize may mean easy performance wins in the future. + + if (this._str) { + return this._str + } + + var str = this.final ? '1' : '0', + labels = Object.keys(this.edges).sort(), + len = labels.length + + for (var i = 0; i < len; i++) { + var label = labels[i], + node = this.edges[label] + + str = str + label + node.id + } + + return str + } + + /** + * Returns a new TokenSet that is the intersection of + * this TokenSet and the passed TokenSet. + * + * This intersection will take into account any wildcards + * contained within the TokenSet. + * + * @param {lunr.TokenSet} b - An other TokenSet to intersect with. + * @returns {lunr.TokenSet} + */ + lunr.TokenSet.prototype.intersect = function (b) { + var output = new lunr.TokenSet, + frame = undefined + + var stack = [{ + qNode: b, + output: output, + node: this + }] + + while (stack.length) { + frame = stack.pop() + + // NOTE: As with the #toString method, we are using + // Object.keys and a for loop instead of a for-in loop + // as both of these objects enter 'hash' mode, causing + // the function to be de-optimised in V8 + var qEdges = Object.keys(frame.qNode.edges), + qLen = qEdges.length, + nEdges = Object.keys(frame.node.edges), + nLen = nEdges.length + + for (var q = 0; q < qLen; q++) { + var qEdge = qEdges[q] + + for (var n = 0; n < nLen; n++) { + var nEdge = nEdges[n] + + if (nEdge == qEdge || qEdge == '*') { + var node = frame.node.edges[nEdge], + qNode = frame.qNode.edges[qEdge], + final = node.final && qNode.final, + next = undefined + + if (nEdge in frame.output.edges) { + // an edge already exists for this character + // no need to create a new node, just set the finality + // bit unless this node is already final + next = frame.output.edges[nEdge] + next.final = next.final || final + + } else { + // no edge exists yet, must create one + // set the finality bit and insert it + // into the output + next = new lunr.TokenSet + next.final = final + frame.output.edges[nEdge] = next + } + + stack.push({ + qNode: qNode, + output: next, + node: node + }) + } + } + } + } + + return output + } + lunr.TokenSet.Builder = function () { + this.previousWord = "" + this.root = new lunr.TokenSet + this.uncheckedNodes = [] + this.minimizedNodes = {} + } + + lunr.TokenSet.Builder.prototype.insert = function (word) { + var node, + commonPrefix = 0 + + if (word < this.previousWord) { + throw new Error ("Out of order word insertion") + } + + for (var i = 0; i < word.length && i < this.previousWord.length; i++) { + if (word[i] != this.previousWord[i]) break + commonPrefix++ + } + + this.minimize(commonPrefix) + + if (this.uncheckedNodes.length == 0) { + node = this.root + } else { + node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child + } + + for (var i = commonPrefix; i < word.length; i++) { + var nextNode = new lunr.TokenSet, + char = word[i] + + node.edges[char] = nextNode + + this.uncheckedNodes.push({ + parent: node, + char: char, + child: nextNode + }) + + node = nextNode + } + + node.final = true + this.previousWord = word + } + + lunr.TokenSet.Builder.prototype.finish = function () { + this.minimize(0) + } + + lunr.TokenSet.Builder.prototype.minimize = function (downTo) { + for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) { + var node = this.uncheckedNodes[i], + childKey = node.child.toString() + + if (childKey in this.minimizedNodes) { + node.parent.edges[node.char] = this.minimizedNodes[childKey] + } else { + // Cache the key for this node since + // we know it can't change anymore + node.child._str = childKey + + this.minimizedNodes[childKey] = node.child + } + + this.uncheckedNodes.pop() + } + } + /*! + * lunr.Index + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * An index contains the built index of all documents and provides a query interface + * to the index. + * + * Usually instances of lunr.Index will not be created using this constructor, instead + * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be + * used to load previously built and serialized indexes. + * + * @constructor + * @param {Object} attrs - The attributes of the built search index. + * @param {Object} attrs.invertedIndex - An index of term/field to document reference. + * @param {Object} attrs.fieldVectors - Field vectors + * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens. + * @param {string[]} attrs.fields - The names of indexed document fields. + * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms. + */ + lunr.Index = function (attrs) { + this.invertedIndex = attrs.invertedIndex + this.fieldVectors = attrs.fieldVectors + this.tokenSet = attrs.tokenSet + this.fields = attrs.fields + this.pipeline = attrs.pipeline + } + + /** + * A result contains details of a document matching a search query. + * @typedef {Object} lunr.Index~Result + * @property {string} ref - The reference of the document this result represents. + * @property {number} score - A number between 0 and 1 representing how similar this document is to the query. + * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match. + */ + + /** + * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple + * query language which itself is parsed into an instance of lunr.Query. + * + * For programmatically building queries it is advised to directly use lunr.Query, the query language + * is best used for human entered text rather than program generated text. + * + * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported + * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello' + * or 'world', though those that contain both will rank higher in the results. + * + * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can + * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding + * wildcards will increase the number of documents that will be found but can also have a negative + * impact on query performance, especially with wildcards at the beginning of a term. + * + * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term + * hello in the title field will match this query. Using a field not present in the index will lead + * to an error being thrown. + * + * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term + * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported + * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2. + * Avoid large values for edit distance to improve query performance. + * + * Each term also supports a presence modifier. By default a term's presence in document is optional, however + * this can be changed to either required or prohibited. For a term's presence to be required in a document the + * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and + * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not + * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'. + * + * To escape special characters the backslash character '\' can be used, this allows searches to include + * characters that would normally be considered modifiers, e.g. `foo\~2` will search for a term "foo~2" instead + * of attempting to apply a boost of 2 to the search term "foo". + * + * @typedef {string} lunr.Index~QueryString + * @example Simple single term query + * hello + * @example Multiple term query + * hello world + * @example term scoped to a field + * title:hello + * @example term with a boost of 10 + * hello^10 + * @example term with an edit distance of 2 + * hello~2 + * @example terms with presence modifiers + * -foo +bar baz + */ + + /** + * Performs a search against the index using lunr query syntax. + * + * Results will be returned sorted by their score, the most relevant results + * will be returned first. For details on how the score is calculated, please see + * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}. + * + * For more programmatic querying use lunr.Index#query. + * + * @param {lunr.Index~QueryString} queryString - A string containing a lunr query. + * @throws {lunr.QueryParseError} If the passed query string cannot be parsed. + * @returns {lunr.Index~Result[]} + */ + lunr.Index.prototype.search = function (queryString) { + return this.query(function (query) { + var parser = new lunr.QueryParser(queryString, query) + parser.parse() + }) + } + + /** + * A query builder callback provides a query object to be used to express + * the query to perform on the index. + * + * @callback lunr.Index~queryBuilder + * @param {lunr.Query} query - The query object to build up. + * @this lunr.Query + */ + + /** + * Performs a query against the index using the yielded lunr.Query object. + * + * If performing programmatic queries against the index, this method is preferred + * over lunr.Index#search so as to avoid the additional query parsing overhead. + * + * A query object is yielded to the supplied function which should be used to + * express the query to be run against the index. + * + * Note that although this function takes a callback parameter it is _not_ an + * asynchronous operation, the callback is just yielded a query object to be + * customized. + * + * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query. + * @returns {lunr.Index~Result[]} + */ + lunr.Index.prototype.query = function (fn) { + // for each query clause + // * process terms + // * expand terms from token set + // * find matching documents and metadata + // * get document vectors + // * score documents + + var query = new lunr.Query(this.fields), + matchingFields = Object.create(null), + queryVectors = Object.create(null), + termFieldCache = Object.create(null), + requiredMatches = Object.create(null), + prohibitedMatches = Object.create(null) + + /* + * To support field level boosts a query vector is created per + * field. An empty vector is eagerly created to support negated + * queries. + */ + for (var i = 0; i < this.fields.length; i++) { + queryVectors[this.fields[i]] = new lunr.Vector + } + + fn.call(query, query) + + for (var i = 0; i < query.clauses.length; i++) { + /* + * Unless the pipeline has been disabled for this term, which is + * the case for terms with wildcards, we need to pass the clause + * term through the search pipeline. A pipeline returns an array + * of processed terms. Pipeline functions may expand the passed + * term, which means we may end up performing multiple index lookups + * for a single query term. + */ + var clause = query.clauses[i], + terms = null, + clauseMatches = lunr.Set.empty + + if (clause.usePipeline) { + terms = this.pipeline.runString(clause.term, { + fields: clause.fields + }) + } else { + terms = [clause.term] + } + + for (var m = 0; m < terms.length; m++) { + var term = terms[m] + + /* + * Each term returned from the pipeline needs to use the same query + * clause object, e.g. the same boost and or edit distance. The + * simplest way to do this is to re-use the clause object but mutate + * its term property. + */ + clause.term = term + + /* + * From the term in the clause we create a token set which will then + * be used to intersect the indexes token set to get a list of terms + * to lookup in the inverted index + */ + var termTokenSet = lunr.TokenSet.fromClause(clause), + expandedTerms = this.tokenSet.intersect(termTokenSet).toArray() + + /* + * If a term marked as required does not exist in the tokenSet it is + * impossible for the search to return any matches. We set all the field + * scoped required matches set to empty and stop examining any further + * clauses. + */ + if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) { + for (var k = 0; k < clause.fields.length; k++) { + var field = clause.fields[k] + requiredMatches[field] = lunr.Set.empty + } + + break + } + + for (var j = 0; j < expandedTerms.length; j++) { + /* + * For each term get the posting and termIndex, this is required for + * building the query vector. + */ + var expandedTerm = expandedTerms[j], + posting = this.invertedIndex[expandedTerm], + termIndex = posting._index + + for (var k = 0; k < clause.fields.length; k++) { + /* + * For each field that this query term is scoped by (by default + * all fields are in scope) we need to get all the document refs + * that have this term in that field. + * + * The posting is the entry in the invertedIndex for the matching + * term from above. + */ + var field = clause.fields[k], + fieldPosting = posting[field], + matchingDocumentRefs = Object.keys(fieldPosting), + termField = expandedTerm + "/" + field, + matchingDocumentsSet = new lunr.Set(matchingDocumentRefs) + + /* + * if the presence of this term is required ensure that the matching + * documents are added to the set of required matches for this clause. + * + */ + if (clause.presence == lunr.Query.presence.REQUIRED) { + clauseMatches = clauseMatches.union(matchingDocumentsSet) + + if (requiredMatches[field] === undefined) { + requiredMatches[field] = lunr.Set.complete + } + } + + /* + * if the presence of this term is prohibited ensure that the matching + * documents are added to the set of prohibited matches for this field, + * creating that set if it does not yet exist. + */ + if (clause.presence == lunr.Query.presence.PROHIBITED) { + if (prohibitedMatches[field] === undefined) { + prohibitedMatches[field] = lunr.Set.empty + } + + prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet) + + /* + * Prohibited matches should not be part of the query vector used for + * similarity scoring and no metadata should be extracted so we continue + * to the next field + */ + continue + } + + /* + * The query field vector is populated using the termIndex found for + * the term and a unit value with the appropriate boost applied. + * Using upsert because there could already be an entry in the vector + * for the term we are working with. In that case we just add the scores + * together. + */ + queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b }) + + /** + * If we've already seen this term, field combo then we've already collected + * the matching documents and metadata, no need to go through all that again + */ + if (termFieldCache[termField]) { + continue + } + + for (var l = 0; l < matchingDocumentRefs.length; l++) { + /* + * All metadata for this term/field/document triple + * are then extracted and collected into an instance + * of lunr.MatchData ready to be returned in the query + * results + */ + var matchingDocumentRef = matchingDocumentRefs[l], + matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field), + metadata = fieldPosting[matchingDocumentRef], + fieldMatch + + if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) { + matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata) + } else { + fieldMatch.add(expandedTerm, field, metadata) + } + + } + + termFieldCache[termField] = true + } + } + } + + /** + * If the presence was required we need to update the requiredMatches field sets. + * We do this after all fields for the term have collected their matches because + * the clause terms presence is required in _any_ of the fields not _all_ of the + * fields. + */ + if (clause.presence === lunr.Query.presence.REQUIRED) { + for (var k = 0; k < clause.fields.length; k++) { + var field = clause.fields[k] + requiredMatches[field] = requiredMatches[field].intersect(clauseMatches) + } + } + } + + /** + * Need to combine the field scoped required and prohibited + * matching documents into a global set of required and prohibited + * matches + */ + var allRequiredMatches = lunr.Set.complete, + allProhibitedMatches = lunr.Set.empty + + for (var i = 0; i < this.fields.length; i++) { + var field = this.fields[i] + + if (requiredMatches[field]) { + allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field]) + } + + if (prohibitedMatches[field]) { + allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field]) + } + } + + var matchingFieldRefs = Object.keys(matchingFields), + results = [], + matches = Object.create(null) + + /* + * If the query is negated (contains only prohibited terms) + * we need to get _all_ fieldRefs currently existing in the + * index. This is only done when we know that the query is + * entirely prohibited terms to avoid any cost of getting all + * fieldRefs unnecessarily. + * + * Additionally, blank MatchData must be created to correctly + * populate the results. + */ + if (query.isNegated()) { + matchingFieldRefs = Object.keys(this.fieldVectors) + + for (var i = 0; i < matchingFieldRefs.length; i++) { + var matchingFieldRef = matchingFieldRefs[i] + var fieldRef = lunr.FieldRef.fromString(matchingFieldRef) + matchingFields[matchingFieldRef] = new lunr.MatchData + } + } + + for (var i = 0; i < matchingFieldRefs.length; i++) { + /* + * Currently we have document fields that match the query, but we + * need to return documents. The matchData and scores are combined + * from multiple fields belonging to the same document. + * + * Scores are calculated by field, using the query vectors created + * above, and combined into a final document score using addition. + */ + var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]), + docRef = fieldRef.docRef + + if (!allRequiredMatches.contains(docRef)) { + continue + } + + if (allProhibitedMatches.contains(docRef)) { + continue + } + + var fieldVector = this.fieldVectors[fieldRef], + score = queryVectors[fieldRef.fieldName].similarity(fieldVector), + docMatch + + if ((docMatch = matches[docRef]) !== undefined) { + docMatch.score += score + docMatch.matchData.combine(matchingFields[fieldRef]) + } else { + var match = { + ref: docRef, + score: score, + matchData: matchingFields[fieldRef] + } + matches[docRef] = match + results.push(match) + } + } + + /* + * Sort the results objects by score, highest first. + */ + return results.sort(function (a, b) { + return b.score - a.score + }) + } + + /** + * Prepares the index for JSON serialization. + * + * The schema for this JSON blob will be described in a + * separate JSON schema file. + * + * @returns {Object} + */ + lunr.Index.prototype.toJSON = function () { + var invertedIndex = Object.keys(this.invertedIndex) + .sort() + .map(function (term) { + return [term, this.invertedIndex[term]] + }, this) + + var fieldVectors = Object.keys(this.fieldVectors) + .map(function (ref) { + return [ref, this.fieldVectors[ref].toJSON()] + }, this) + + return { + version: lunr.version, + fields: this.fields, + fieldVectors: fieldVectors, + invertedIndex: invertedIndex, + pipeline: this.pipeline.toJSON() + } + } + + /** + * Loads a previously serialized lunr.Index + * + * @param {Object} serializedIndex - A previously serialized lunr.Index + * @returns {lunr.Index} + */ + lunr.Index.load = function (serializedIndex) { + var attrs = {}, + fieldVectors = {}, + serializedVectors = serializedIndex.fieldVectors, + invertedIndex = Object.create(null), + serializedInvertedIndex = serializedIndex.invertedIndex, + tokenSetBuilder = new lunr.TokenSet.Builder, + pipeline = lunr.Pipeline.load(serializedIndex.pipeline) + + if (serializedIndex.version != lunr.version) { + lunr.utils.warn("Version mismatch when loading serialised index. Current version of lunr '" + lunr.version + "' does not match serialized index '" + serializedIndex.version + "'") + } + + for (var i = 0; i < serializedVectors.length; i++) { + var tuple = serializedVectors[i], + ref = tuple[0], + elements = tuple[1] + + fieldVectors[ref] = new lunr.Vector(elements) + } + + for (var i = 0; i < serializedInvertedIndex.length; i++) { + var tuple = serializedInvertedIndex[i], + term = tuple[0], + posting = tuple[1] + + tokenSetBuilder.insert(term) + invertedIndex[term] = posting + } + + tokenSetBuilder.finish() + + attrs.fields = serializedIndex.fields + + attrs.fieldVectors = fieldVectors + attrs.invertedIndex = invertedIndex + attrs.tokenSet = tokenSetBuilder.root + attrs.pipeline = pipeline + + return new lunr.Index(attrs) + } + /*! + * lunr.Builder + * Copyright (C) 2020 Oliver Nightingale + */ + + /** + * lunr.Builder performs indexing on a set of documents and + * returns instances of lunr.Index ready for querying. + * + * All configuration of the index is done via the builder, the + * fields to index, the document reference, the text processing + * pipeline and document scoring parameters are all set on the + * builder before indexing. + * + * @constructor + * @property {string} _ref - Internal reference to the document reference field. + * @property {string[]} _fields - Internal reference to the document fields to index. + * @property {object} invertedIndex - The inverted index maps terms to document fields. + * @property {object} documentTermFrequencies - Keeps track of document term frequencies. + * @property {object} documentLengths - Keeps track of the length of documents added to the index. + * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing. + * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing. + * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index. + * @property {number} documentCount - Keeps track of the total number of documents indexed. + * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75. + * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2. + * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space. + * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index. + */ + lunr.Builder = function () { + this._ref = "id" + this._fields = Object.create(null) + this._documents = Object.create(null) + this.invertedIndex = Object.create(null) + this.fieldTermFrequencies = {} + this.fieldLengths = {} + this.tokenizer = lunr.tokenizer + this.pipeline = new lunr.Pipeline + this.searchPipeline = new lunr.Pipeline + this.documentCount = 0 + this._b = 0.75 + this._k1 = 1.2 + this.termIndex = 0 + this.metadataWhitelist = [] + } + + /** + * Sets the document field used as the document reference. Every document must have this field. + * The type of this field in the document should be a string, if it is not a string it will be + * coerced into a string by calling toString. + * + * The default ref is 'id'. + * + * The ref should _not_ be changed during indexing, it should be set before any documents are + * added to the index. Changing it during indexing can lead to inconsistent results. + * + * @param {string} ref - The name of the reference field in the document. + */ + lunr.Builder.prototype.ref = function (ref) { + this._ref = ref + } + + /** + * A function that is used to extract a field from a document. + * + * Lunr expects a field to be at the top level of a document, if however the field + * is deeply nested within a document an extractor function can be used to extract + * the right field for indexing. + * + * @callback fieldExtractor + * @param {object} doc - The document being added to the index. + * @returns {?(string|object|object[])} obj - The object that will be indexed for this field. + * @example Extracting a nested field + * function (doc) { return doc.nested.field } + */ + + /** + * Adds a field to the list of document fields that will be indexed. Every document being + * indexed should have this field. Null values for this field in indexed documents will + * not cause errors but will limit the chance of that document being retrieved by searches. + * + * All fields should be added before adding documents to the index. Adding fields after + * a document has been indexed will have no effect on already indexed documents. + * + * Fields can be boosted at build time. This allows terms within that field to have more + * importance when ranking search results. Use a field boost to specify that matches within + * one field are more important than other fields. + * + * @param {string} fieldName - The name of a field to index in all documents. + * @param {object} attributes - Optional attributes associated with this field. + * @param {number} [attributes.boost=1] - Boost applied to all terms within this field. + * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document. + * @throws {RangeError} fieldName cannot contain unsupported characters '/' + */ + lunr.Builder.prototype.field = function (fieldName, attributes) { + if (/\//.test(fieldName)) { + throw new RangeError ("Field '" + fieldName + "' contains illegal character '/'") + } + + this._fields[fieldName] = attributes || {} + } + + /** + * A parameter to tune the amount of field length normalisation that is applied when + * calculating relevance scores. A value of 0 will completely disable any normalisation + * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b + * will be clamped to the range 0 - 1. + * + * @param {number} number - The value to set for this tuning parameter. + */ + lunr.Builder.prototype.b = function (number) { + if (number < 0) { + this._b = 0 + } else if (number > 1) { + this._b = 1 + } else { + this._b = number + } + } + + /** + * A parameter that controls the speed at which a rise in term frequency results in term + * frequency saturation. The default value is 1.2. Setting this to a higher value will give + * slower saturation levels, a lower value will result in quicker saturation. + * + * @param {number} number - The value to set for this tuning parameter. + */ + lunr.Builder.prototype.k1 = function (number) { + this._k1 = number + } + + /** + * Adds a document to the index. + * + * Before adding fields to the index the index should have been fully setup, with the document + * ref and all fields to index already having been specified. + * + * The document must have a field name as specified by the ref (by default this is 'id') and + * it should have all fields defined for indexing, though null or undefined values will not + * cause errors. + * + * Entire documents can be boosted at build time. Applying a boost to a document indicates that + * this document should rank higher in search results than other documents. + * + * @param {object} doc - The document to add to the index. + * @param {object} attributes - Optional attributes associated with this document. + * @param {number} [attributes.boost=1] - Boost applied to all terms within this document. + */ + lunr.Builder.prototype.add = function (doc, attributes) { + var docRef = doc[this._ref], + fields = Object.keys(this._fields) + + this._documents[docRef] = attributes || {} + this.documentCount += 1 + + for (var i = 0; i < fields.length; i++) { + var fieldName = fields[i], + extractor = this._fields[fieldName].extractor, + field = extractor ? extractor(doc) : doc[fieldName], + tokens = this.tokenizer(field, { + fields: [fieldName] + }), + terms = this.pipeline.run(tokens), + fieldRef = new lunr.FieldRef (docRef, fieldName), + fieldTerms = Object.create(null) + + this.fieldTermFrequencies[fieldRef] = fieldTerms + this.fieldLengths[fieldRef] = 0 + + // store the length of this field for this document + this.fieldLengths[fieldRef] += terms.length + + // calculate term frequencies for this field + for (var j = 0; j < terms.length; j++) { + var term = terms[j] + + if (fieldTerms[term] == undefined) { + fieldTerms[term] = 0 + } + + fieldTerms[term] += 1 + + // add to inverted index + // create an initial posting if one doesn't exist + if (this.invertedIndex[term] == undefined) { + var posting = Object.create(null) + posting["_index"] = this.termIndex + this.termIndex += 1 + + for (var k = 0; k < fields.length; k++) { + posting[fields[k]] = Object.create(null) + } + + this.invertedIndex[term] = posting + } + + // add an entry for this term/fieldName/docRef to the invertedIndex + if (this.invertedIndex[term][fieldName][docRef] == undefined) { + this.invertedIndex[term][fieldName][docRef] = Object.create(null) + } + + // store all whitelisted metadata about this token in the + // inverted index + for (var l = 0; l < this.metadataWhitelist.length; l++) { + var metadataKey = this.metadataWhitelist[l], + metadata = term.metadata[metadataKey] + + if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) { + this.invertedIndex[term][fieldName][docRef][metadataKey] = [] + } + + this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata) + } + } + + } + } + + /** + * Calculates the average document length for this index + * + * @private + */ + lunr.Builder.prototype.calculateAverageFieldLengths = function () { + + var fieldRefs = Object.keys(this.fieldLengths), + numberOfFields = fieldRefs.length, + accumulator = {}, + documentsWithField = {} + + for (var i = 0; i < numberOfFields; i++) { + var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]), + field = fieldRef.fieldName + + documentsWithField[field] || (documentsWithField[field] = 0) + documentsWithField[field] += 1 + + accumulator[field] || (accumulator[field] = 0) + accumulator[field] += this.fieldLengths[fieldRef] + } + + var fields = Object.keys(this._fields) + + for (var i = 0; i < fields.length; i++) { + var fieldName = fields[i] + accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName] + } + + this.averageFieldLength = accumulator + } + + /** + * Builds a vector space model of every document using lunr.Vector + * + * @private + */ + lunr.Builder.prototype.createFieldVectors = function () { + var fieldVectors = {}, + fieldRefs = Object.keys(this.fieldTermFrequencies), + fieldRefsLength = fieldRefs.length, + termIdfCache = Object.create(null) + + for (var i = 0; i < fieldRefsLength; i++) { + var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]), + fieldName = fieldRef.fieldName, + fieldLength = this.fieldLengths[fieldRef], + fieldVector = new lunr.Vector, + termFrequencies = this.fieldTermFrequencies[fieldRef], + terms = Object.keys(termFrequencies), + termsLength = terms.length + + + var fieldBoost = this._fields[fieldName].boost || 1, + docBoost = this._documents[fieldRef.docRef].boost || 1 + + for (var j = 0; j < termsLength; j++) { + var term = terms[j], + tf = termFrequencies[term], + termIndex = this.invertedIndex[term]._index, + idf, score, scoreWithPrecision + + if (termIdfCache[term] === undefined) { + idf = lunr.idf(this.invertedIndex[term], this.documentCount) + termIdfCache[term] = idf + } else { + idf = termIdfCache[term] + } + + score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf) + score *= fieldBoost + score *= docBoost + scoreWithPrecision = Math.round(score * 1000) / 1000 + // Converts 1.23456789 to 1.234. + // Reducing the precision so that the vectors take up less + // space when serialised. Doing it now so that they behave + // the same before and after serialisation. Also, this is + // the fastest approach to reducing a number's precision in + // JavaScript. + + fieldVector.insert(termIndex, scoreWithPrecision) + } + + fieldVectors[fieldRef] = fieldVector + } + + this.fieldVectors = fieldVectors + } + + /** + * Creates a token set of all tokens in the index using lunr.TokenSet + * + * @private + */ + lunr.Builder.prototype.createTokenSet = function () { + this.tokenSet = lunr.TokenSet.fromArray( + Object.keys(this.invertedIndex).sort() + ) + } + + /** + * Builds the index, creating an instance of lunr.Index. + * + * This completes the indexing process and should only be called + * once all documents have been added to the index. + * + * @returns {lunr.Index} + */ + lunr.Builder.prototype.build = function () { + this.calculateAverageFieldLengths() + this.createFieldVectors() + this.createTokenSet() + + return new lunr.Index({ + invertedIndex: this.invertedIndex, + fieldVectors: this.fieldVectors, + tokenSet: this.tokenSet, + fields: Object.keys(this._fields), + pipeline: this.searchPipeline + }) + } + + /** + * Applies a plugin to the index builder. + * + * A plugin is a function that is called with the index builder as its context. + * Plugins can be used to customise or extend the behaviour of the index + * in some way. A plugin is just a function, that encapsulated the custom + * behaviour that should be applied when building the index. + * + * The plugin function will be called with the index builder as its argument, additional + * arguments can also be passed when calling use. The function will be called + * with the index builder as its context. + * + * @param {Function} plugin The plugin to apply. + */ + lunr.Builder.prototype.use = function (fn) { + var args = Array.prototype.slice.call(arguments, 1) + args.unshift(this) + fn.apply(this, args) + } + /** + * Contains and collects metadata about a matching document. + * A single instance of lunr.MatchData is returned as part of every + * lunr.Index~Result. + * + * @constructor + * @param {string} term - The term this match data is associated with + * @param {string} field - The field in which the term was found + * @param {object} metadata - The metadata recorded about this term in this field + * @property {object} metadata - A cloned collection of metadata associated with this document. + * @see {@link lunr.Index~Result} + */ + lunr.MatchData = function (term, field, metadata) { + var clonedMetadata = Object.create(null), + metadataKeys = Object.keys(metadata || {}) + + // Cloning the metadata to prevent the original + // being mutated during match data combination. + // Metadata is kept in an array within the inverted + // index so cloning the data can be done with + // Array#slice + for (var i = 0; i < metadataKeys.length; i++) { + var key = metadataKeys[i] + clonedMetadata[key] = metadata[key].slice() + } + + this.metadata = Object.create(null) + + if (term !== undefined) { + this.metadata[term] = Object.create(null) + this.metadata[term][field] = clonedMetadata + } + } + + /** + * An instance of lunr.MatchData will be created for every term that matches a + * document. However only one instance is required in a lunr.Index~Result. This + * method combines metadata from another instance of lunr.MatchData with this + * objects metadata. + * + * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one. + * @see {@link lunr.Index~Result} + */ + lunr.MatchData.prototype.combine = function (otherMatchData) { + var terms = Object.keys(otherMatchData.metadata) + + for (var i = 0; i < terms.length; i++) { + var term = terms[i], + fields = Object.keys(otherMatchData.metadata[term]) + + if (this.metadata[term] == undefined) { + this.metadata[term] = Object.create(null) + } + + for (var j = 0; j < fields.length; j++) { + var field = fields[j], + keys = Object.keys(otherMatchData.metadata[term][field]) + + if (this.metadata[term][field] == undefined) { + this.metadata[term][field] = Object.create(null) + } + + for (var k = 0; k < keys.length; k++) { + var key = keys[k] + + if (this.metadata[term][field][key] == undefined) { + this.metadata[term][field][key] = otherMatchData.metadata[term][field][key] + } else { + this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key]) + } + + } + } + } + } + + /** + * Add metadata for a term/field pair to this instance of match data. + * + * @param {string} term - The term this match data is associated with + * @param {string} field - The field in which the term was found + * @param {object} metadata - The metadata recorded about this term in this field + */ + lunr.MatchData.prototype.add = function (term, field, metadata) { + if (!(term in this.metadata)) { + this.metadata[term] = Object.create(null) + this.metadata[term][field] = metadata + return + } + + if (!(field in this.metadata[term])) { + this.metadata[term][field] = metadata + return + } + + var metadataKeys = Object.keys(metadata) + + for (var i = 0; i < metadataKeys.length; i++) { + var key = metadataKeys[i] + + if (key in this.metadata[term][field]) { + this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key]) + } else { + this.metadata[term][field][key] = metadata[key] + } + } + } + /** + * A lunr.Query provides a programmatic way of defining queries to be performed + * against a {@link lunr.Index}. + * + * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method + * so the query object is pre-initialized with the right index fields. + * + * @constructor + * @property {lunr.Query~Clause[]} clauses - An array of query clauses. + * @property {string[]} allFields - An array of all available fields in a lunr.Index. + */ + lunr.Query = function (allFields) { + this.clauses = [] + this.allFields = allFields + } + + /** + * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause. + * + * This allows wildcards to be added to the beginning and end of a term without having to manually do any string + * concatenation. + * + * The wildcard constants can be bitwise combined to select both leading and trailing wildcards. + * + * @constant + * @default + * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour + * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists + * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists + * @see lunr.Query~Clause + * @see lunr.Query#clause + * @see lunr.Query#term + * @example query term with trailing wildcard + * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING }) + * @example query term with leading and trailing wildcard + * query.term('foo', { + * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING + * }) + */ + + lunr.Query.wildcard = new String ("*") + lunr.Query.wildcard.NONE = 0 + lunr.Query.wildcard.LEADING = 1 + lunr.Query.wildcard.TRAILING = 2 + + /** + * Constants for indicating what kind of presence a term must have in matching documents. + * + * @constant + * @enum {number} + * @see lunr.Query~Clause + * @see lunr.Query#clause + * @see lunr.Query#term + * @example query term with required presence + * query.term('foo', { presence: lunr.Query.presence.REQUIRED }) + */ + lunr.Query.presence = { + /** + * Term's presence in a document is optional, this is the default value. + */ + OPTIONAL: 1, + + /** + * Term's presence in a document is required, documents that do not contain + * this term will not be returned. + */ + REQUIRED: 2, + + /** + * Term's presence in a document is prohibited, documents that do contain + * this term will not be returned. + */ + PROHIBITED: 3 + } + + /** + * A single clause in a {@link lunr.Query} contains a term and details on how to + * match that term against a {@link lunr.Index}. + * + * @typedef {Object} lunr.Query~Clause + * @property {string[]} fields - The fields in an index this clause should be matched against. + * @property {number} [boost=1] - Any boost that should be applied when matching this clause. + * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be. + * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline. + * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended. + * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents. + */ + + /** + * Adds a {@link lunr.Query~Clause} to this query. + * + * Unless the clause contains the fields to be matched all fields will be matched. In addition + * a default boost of 1 is applied to the clause. + * + * @param {lunr.Query~Clause} clause - The clause to add to this query. + * @see lunr.Query~Clause + * @returns {lunr.Query} + */ + lunr.Query.prototype.clause = function (clause) { + if (!('fields' in clause)) { + clause.fields = this.allFields + } + + if (!('boost' in clause)) { + clause.boost = 1 + } + + if (!('usePipeline' in clause)) { + clause.usePipeline = true + } + + if (!('wildcard' in clause)) { + clause.wildcard = lunr.Query.wildcard.NONE + } + + if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) { + clause.term = "*" + clause.term + } + + if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) { + clause.term = "" + clause.term + "*" + } + + if (!('presence' in clause)) { + clause.presence = lunr.Query.presence.OPTIONAL + } + + this.clauses.push(clause) + + return this + } + + /** + * A negated query is one in which every clause has a presence of + * prohibited. These queries require some special processing to return + * the expected results. + * + * @returns boolean + */ + lunr.Query.prototype.isNegated = function () { + for (var i = 0; i < this.clauses.length; i++) { + if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) { + return false + } + } + + return true + } + + /** + * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause} + * to the list of clauses that make up this query. + * + * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion + * to a token or token-like string should be done before calling this method. + * + * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an + * array, each term in the array will share the same options. + * + * @param {object|object[]} term - The term(s) to add to the query. + * @param {object} [options] - Any additional properties to add to the query clause. + * @returns {lunr.Query} + * @see lunr.Query#clause + * @see lunr.Query~Clause + * @example adding a single term to a query + * query.term("foo") + * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard + * query.term("foo", { + * fields: ["title"], + * boost: 10, + * wildcard: lunr.Query.wildcard.TRAILING + * }) + * @example using lunr.tokenizer to convert a string to tokens before using them as terms + * query.term(lunr.tokenizer("foo bar")) + */ + lunr.Query.prototype.term = function (term, options) { + if (Array.isArray(term)) { + term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this) + return this + } + + var clause = options || {} + clause.term = term.toString() + + this.clause(clause) + + return this + } + lunr.QueryParseError = function (message, start, end) { + this.name = "QueryParseError" + this.message = message + this.start = start + this.end = end + } + + lunr.QueryParseError.prototype = new Error + lunr.QueryLexer = function (str) { + this.lexemes = [] + this.str = str + this.length = str.length + this.pos = 0 + this.start = 0 + this.escapeCharPositions = [] + } + + lunr.QueryLexer.prototype.run = function () { + var state = lunr.QueryLexer.lexText + + while (state) { + state = state(this) + } + } + + lunr.QueryLexer.prototype.sliceString = function () { + var subSlices = [], + sliceStart = this.start, + sliceEnd = this.pos + + for (var i = 0; i < this.escapeCharPositions.length; i++) { + sliceEnd = this.escapeCharPositions[i] + subSlices.push(this.str.slice(sliceStart, sliceEnd)) + sliceStart = sliceEnd + 1 + } + + subSlices.push(this.str.slice(sliceStart, this.pos)) + this.escapeCharPositions.length = 0 + + return subSlices.join('') + } + + lunr.QueryLexer.prototype.emit = function (type) { + this.lexemes.push({ + type: type, + str: this.sliceString(), + start: this.start, + end: this.pos + }) + + this.start = this.pos + } + + lunr.QueryLexer.prototype.escapeCharacter = function () { + this.escapeCharPositions.push(this.pos - 1) + this.pos += 1 + } + + lunr.QueryLexer.prototype.next = function () { + if (this.pos >= this.length) { + return lunr.QueryLexer.EOS + } + + var char = this.str.charAt(this.pos) + this.pos += 1 + return char + } + + lunr.QueryLexer.prototype.width = function () { + return this.pos - this.start + } + + lunr.QueryLexer.prototype.ignore = function () { + if (this.start == this.pos) { + this.pos += 1 + } + + this.start = this.pos + } + + lunr.QueryLexer.prototype.backup = function () { + this.pos -= 1 + } + + lunr.QueryLexer.prototype.acceptDigitRun = function () { + var char, charCode + + do { + char = this.next() + charCode = char.charCodeAt(0) + } while (charCode > 47 && charCode < 58) + + if (char != lunr.QueryLexer.EOS) { + this.backup() + } + } + + lunr.QueryLexer.prototype.more = function () { + return this.pos < this.length + } + + lunr.QueryLexer.EOS = 'EOS' + lunr.QueryLexer.FIELD = 'FIELD' + lunr.QueryLexer.TERM = 'TERM' + lunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE' + lunr.QueryLexer.BOOST = 'BOOST' + lunr.QueryLexer.PRESENCE = 'PRESENCE' + + lunr.QueryLexer.lexField = function (lexer) { + lexer.backup() + lexer.emit(lunr.QueryLexer.FIELD) + lexer.ignore() + return lunr.QueryLexer.lexText + } + + lunr.QueryLexer.lexTerm = function (lexer) { + if (lexer.width() > 1) { + lexer.backup() + lexer.emit(lunr.QueryLexer.TERM) + } + + lexer.ignore() + + if (lexer.more()) { + return lunr.QueryLexer.lexText + } + } + + lunr.QueryLexer.lexEditDistance = function (lexer) { + lexer.ignore() + lexer.acceptDigitRun() + lexer.emit(lunr.QueryLexer.EDIT_DISTANCE) + return lunr.QueryLexer.lexText + } + + lunr.QueryLexer.lexBoost = function (lexer) { + lexer.ignore() + lexer.acceptDigitRun() + lexer.emit(lunr.QueryLexer.BOOST) + return lunr.QueryLexer.lexText + } + + lunr.QueryLexer.lexEOS = function (lexer) { + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } + } + + // This matches the separator used when tokenising fields + // within a document. These should match otherwise it is + // not possible to search for some tokens within a document. + // + // It is possible for the user to change the separator on the + // tokenizer so it _might_ clash with any other of the special + // characters already used within the search string, e.g. :. + // + // This means that it is possible to change the separator in + // such a way that makes some words unsearchable using a search + // string. + lunr.QueryLexer.termSeparator = lunr.tokenizer.separator + + lunr.QueryLexer.lexText = function (lexer) { + while (true) { + var char = lexer.next() + + if (char == lunr.QueryLexer.EOS) { + return lunr.QueryLexer.lexEOS + } + + // Escape character is '\' + if (char.charCodeAt(0) == 92) { + lexer.escapeCharacter() + continue + } + + if (char == ":") { + return lunr.QueryLexer.lexField + } + + if (char == "~") { + lexer.backup() + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } + return lunr.QueryLexer.lexEditDistance + } + + if (char == "^") { + lexer.backup() + if (lexer.width() > 0) { + lexer.emit(lunr.QueryLexer.TERM) + } + return lunr.QueryLexer.lexBoost + } + + // "+" indicates term presence is required + // checking for length to ensure that only + // leading "+" are considered + if (char == "+" && lexer.width() === 1) { + lexer.emit(lunr.QueryLexer.PRESENCE) + return lunr.QueryLexer.lexText + } + + // "-" indicates term presence is prohibited + // checking for length to ensure that only + // leading "-" are considered + if (char == "-" && lexer.width() === 1) { + lexer.emit(lunr.QueryLexer.PRESENCE) + return lunr.QueryLexer.lexText + } + + if (char.match(lunr.QueryLexer.termSeparator)) { + return lunr.QueryLexer.lexTerm + } + } + } + + lunr.QueryParser = function (str, query) { + this.lexer = new lunr.QueryLexer (str) + this.query = query + this.currentClause = {} + this.lexemeIdx = 0 + } + + lunr.QueryParser.prototype.parse = function () { + this.lexer.run() + this.lexemes = this.lexer.lexemes + + var state = lunr.QueryParser.parseClause + + while (state) { + state = state(this) + } + + return this.query + } + + lunr.QueryParser.prototype.peekLexeme = function () { + return this.lexemes[this.lexemeIdx] + } + + lunr.QueryParser.prototype.consumeLexeme = function () { + var lexeme = this.peekLexeme() + this.lexemeIdx += 1 + return lexeme + } + + lunr.QueryParser.prototype.nextClause = function () { + var completedClause = this.currentClause + this.query.clause(completedClause) + this.currentClause = {} + } + + lunr.QueryParser.parseClause = function (parser) { + var lexeme = parser.peekLexeme() + + if (lexeme == undefined) { + return + } + + switch (lexeme.type) { + case lunr.QueryLexer.PRESENCE: + return lunr.QueryParser.parsePresence + case lunr.QueryLexer.FIELD: + return lunr.QueryParser.parseField + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expected either a field or a term, found " + lexeme.type + + if (lexeme.str.length >= 1) { + errorMessage += " with value '" + lexeme.str + "'" + } + + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + } + + lunr.QueryParser.parsePresence = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + switch (lexeme.str) { + case "-": + parser.currentClause.presence = lunr.Query.presence.PROHIBITED + break + case "+": + parser.currentClause.presence = lunr.Query.presence.REQUIRED + break + default: + var errorMessage = "unrecognised presence operator'" + lexeme.str + "'" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + var errorMessage = "expecting term or field, found nothing" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.FIELD: + return lunr.QueryParser.parseField + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expecting term or field, found '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } + } + + lunr.QueryParser.parseField = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + if (parser.query.allFields.indexOf(lexeme.str) == -1) { + var possibleFields = parser.query.allFields.map(function (f) { return "'" + f + "'" }).join(', '), + errorMessage = "unrecognised field '" + lexeme.str + "', possible fields: " + possibleFields + + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.fields = [lexeme.str] + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + var errorMessage = "expecting term, found nothing" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + return lunr.QueryParser.parseTerm + default: + var errorMessage = "expecting term, found '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } + } + + lunr.QueryParser.parseTerm = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + parser.currentClause.term = lexeme.str.toLowerCase() + + if (lexeme.str.indexOf("*") != -1) { + parser.currentClause.usePipeline = false + } + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } + } + + lunr.QueryParser.parseEditDistance = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + var editDistance = parseInt(lexeme.str, 10) + + if (isNaN(editDistance)) { + var errorMessage = "edit distance must be numeric" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.editDistance = editDistance + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } + } + + lunr.QueryParser.parseBoost = function (parser) { + var lexeme = parser.consumeLexeme() + + if (lexeme == undefined) { + return + } + + var boost = parseInt(lexeme.str, 10) + + if (isNaN(boost)) { + var errorMessage = "boost must be numeric" + throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end) + } + + parser.currentClause.boost = boost + + var nextLexeme = parser.peekLexeme() + + if (nextLexeme == undefined) { + parser.nextClause() + return + } + + switch (nextLexeme.type) { + case lunr.QueryLexer.TERM: + parser.nextClause() + return lunr.QueryParser.parseTerm + case lunr.QueryLexer.FIELD: + parser.nextClause() + return lunr.QueryParser.parseField + case lunr.QueryLexer.EDIT_DISTANCE: + return lunr.QueryParser.parseEditDistance + case lunr.QueryLexer.BOOST: + return lunr.QueryParser.parseBoost + case lunr.QueryLexer.PRESENCE: + parser.nextClause() + return lunr.QueryParser.parsePresence + default: + var errorMessage = "Unexpected lexeme type '" + nextLexeme.type + "'" + throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end) + } + } + + /** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ + ;(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like enviroments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + root.lunr = factory() + } + }(this, function () { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return lunr + })) + })(); \ No newline at end of file diff --git a/assets/js/search.js b/assets/js/search.js new file mode 100644 index 0000000..d2cf0ad --- /dev/null +++ b/assets/js/search.js @@ -0,0 +1,45 @@ +// based on https://victoria.dev/blog/add-search-to-hugo-static-sites-with-lunr/ +function displayResults (results, store) { + const searchResults = document.getElementById('results'); + if (results.length) { + let resultList = ''; + for (const n in results) { + const item = store[results[n].ref]; + resultList += '
  • ' + item.title + '
  • ' + if (item.description) + resultList += '

    ' + item.description + '

    ' + else + resultList += '

    ' + item.content.substring(0, 150) + '...

    ' + } + searchResults.innerHTML = resultList; + } else { + searchResults.innerHTML = 'No results found.'; + } +} +const params = new URLSearchParams(window.location.search); +const query = params.get('query'); +if (query) { + document.getElementById('search-query').setAttribute('value', query); + const idx = lunr(function () { + this.ref('id') + this.field('title', { + boost: 15 + }) + this.field('tags') + this.field('content', { + boost: 10 + }) + for (const key in window.store) { + this.add({ + id: key, + title: window.store[key].title, + tags: window.store[key].tags, + content: window.store[key].content + }) + } + }) + const results = idx.search(query); + displayResults(results, window.store) +} + + diff --git a/build.sh b/build.sh index 3d63676..78499bd 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Quick script to run local builds source .env -hugo --minify --environment local -D +hugo --environment local -D npx torchlight python3 -m http.server --directory public 1313 diff --git a/config/_default/hugo.toml b/config/_default/hugo.toml index c6155e5..f7f30ab 100644 --- a/config/_default/hugo.toml +++ b/config/_default/hugo.toml @@ -11,7 +11,7 @@ enableInlineShortcodes = true # sectionPagesMenu = "main" [outputs] - home = ['html', 'rss', 'json'] + home = ['html', 'rss'] section = ['html'] taxonomy = ['html',] term = ['html', 'rss'] @@ -58,5 +58,8 @@ enableInlineShortcodes = true [taxonomies] tag = "tags" - series = "series" + category = "categories" +[minify] + disableXML = true + minifyOutput = true \ No newline at end of file diff --git a/config/_default/menu.toml b/config/_default/menu.toml index a4b6fee..01fd711 100644 --- a/config/_default/menu.toml +++ b/config/_default/menu.toml @@ -5,21 +5,21 @@ # weight = 10 [[main]] - identifier = "projects" - name = "projects" - url = "/series/projects/" + identifier = "self-hosting" + name = "self-hosting" + url = "/categories/self-hosting/" weight = 1 [[main]] identifier = "tips" name = "tips" - url = "/series/tips/" + url = "/categories/tips/" weight = 1 [[main]] identifier = "code" name = "code" - url = "/series/code/" + url = "/categories/code/" weight = 1 [[main]] diff --git a/config/_default/params.toml b/config/_default/params.toml index a329dfa..c20f40a 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -18,7 +18,7 @@ giscusInputPosition = "bottom" giscusLang = "en" giscusLoading = "lazy" giscusMapping = "og:title" -giscusReactions = "1" +giscusReactions = "0" giscusRepo = "jbowdre/site-comments" giscusRepoId = "R_kgDOKKEGDw" giscusStrict = "0" @@ -171,8 +171,8 @@ title = "hugo" url = "https://gohugo.io" [[powerLinks]] -title = "netlify" -url = "https://www.netlify.com" +title = "neocities" +url = "https://neocities.org/about" [[powerLinks]] title = "risotto" @@ -183,8 +183,8 @@ title = "torchlight" url = "https://torchlight.dev" [[powerLinks]] -title = "cabin" -url = "https://withcabin.com/privacy/runtimeterror.dev" +title = "tinylytics" +url = "https://tinylytics.app/home" [[verifyLinks]] title = "omg.lol" diff --git a/content/404.md b/content/404.md index 9298bdd..c30b7c9 100644 --- a/content/404.md +++ b/content/404.md @@ -1,12 +1,13 @@ +++ title = "404'd!" +aliases = ["not_found"] noindex = true timeless = true comments = true +++ We're not sure what you were looking for but it's not here. -![](/images/nothing-to-see-here.gif) +![Animated GIF from the movie "The Naked Gun". A man in the foreground proclaims "Please disperse. Nothing to see here." while a building explodes in the background.](/images/nothing-to-see-here.gif) Maybe head back [home](/)? diff --git a/content/about.md b/content/about.md index ad4599f..932079e 100644 --- a/content/about.md +++ b/content/about.md @@ -11,11 +11,11 @@ You've (somehow) managed to stumble upon my dark corner of the internet[^1]. I've enjoyed tinkering with computers and their code since discovering I could alter variable values in [`GORILLA.BAS`](https://en.wikipedia.org/wiki/Gorillas_%28video_game%29) on my dad's work computer to imbue the thrown bananas with enough explosive power to level the entire city. I thought, "hey, that's neat," and then spent much of my childhood free time learning how *else* I could bend computers to my will. -Once I grew up[^2], I found a career in system administration, and I leveraged my passion for coding to write scripts to help manage systems more efficiently. While managing a global-scale VMware environment, I was tasked with implementing [vRealize Automation](/series/vra8) (now called "Aria Automation"). I didn't realize it at the time but that was the start of my DevOps transformation. I started thinking about infrastructure-as-code, and began using [HashiCorp Packer](https://github.com/jbowdre/packer-vsphere-templates) and a CI/CD pipeline to automatically build fully-up-to-date VM templates on a weekly cadence. +Once I grew up[^2], I found a career in system administration, and I leveraged my passion for coding to write scripts to help manage systems more efficiently. While managing a global-scale VMware environment, I was tasked with implementing [vRealize Automation](/categories/vmware) (now called "Aria Automation"). I didn't realize it at the time but that was the start of my DevOps transformation. I started thinking about infrastructure-as-code, and began using [HashiCorp Packer](https://github.com/jbowdre/packer-vsphere-templates) and a CI/CD pipeline to automatically build fully-up-to-date VM templates on a weekly cadence. I'm now part of a small platform engineering team within that same large corporation, focused on leveraging DevOps thinking and tools to help our internal customers modernize how they operate IT, build code, and ship products, while designing solutions to help them accomplish those goals. It's a great blend of my virtual infrastructure operations background, hobbyist development experience, and hunger for solving problems, and I really enjoy applying these skills to solve interesting challenges at scale. -On my off time, I tinker with new [projects](/series/projects) in my little homelab (and share some of those adventures here). I also help out on Google's product support forums as a [Product Expert](https://productexperts.withgoogle.com/what-it-is), where I support Pixel phones, earbuds, and watches, as well as Chromebooks (primarily with Linux-related queries). Helping users troubleshoot their issues scratches my problem-solving itch, and it keeps me connected with some really great like-minded tech enthusiasts. +On my off time, I tinker with new [projects](/categories/self-hosting) in my little homelab (and share some of those adventures here). I also help out on Google's product support forums as a [Product Expert](https://productexperts.withgoogle.com/what-it-is), where I support Pixel phones, earbuds, and watches, as well as Chromebooks (primarily with Linux-related queries). Helping users troubleshoot their issues scratches my problem-solving itch, and it keeps me connected with some really great like-minded tech enthusiasts. On weekends, I race my daily-driven 2014 Subaru BRZ in local [autocross events](https://l.runtimeterror.dev/my-autox-vids) or wrench on my 1974 Volkswagen Karmann Ghia. diff --git a/content/categories/backstage/_index.md b/content/categories/backstage/_index.md new file mode 100644 index 0000000..3ba2df5 --- /dev/null +++ b/content/categories/backstage/_index.md @@ -0,0 +1,5 @@ +--- +title: Backstage +description: > + A peek behind the scenes at what it takes to run this site. +--- \ No newline at end of file diff --git a/content/categories/chromeos/_index.md b/content/categories/chromeos/_index.md new file mode 100644 index 0000000..69d9943 --- /dev/null +++ b/content/categories/chromeos/_index.md @@ -0,0 +1,5 @@ +--- +title: "ChromeOS" +description: > + My Chromebook is a lot more than just a browser. +--- \ No newline at end of file diff --git a/content/categories/code/_index.md b/content/categories/code/_index.md new file mode 100644 index 0000000..cefa911 --- /dev/null +++ b/content/categories/code/_index.md @@ -0,0 +1,5 @@ +--- +title: Code +description: > + I did a programming and I wanted you to see. +--- \ No newline at end of file diff --git a/content/categories/self-hosting/_index.md b/content/categories/self-hosting/_index.md new file mode 100644 index 0000000..8964bc4 --- /dev/null +++ b/content/categories/self-hosting/_index.md @@ -0,0 +1,5 @@ +--- +title: Self-Hosting +description: > + Never met an app I didn't want to deploy. +--- \ No newline at end of file diff --git a/content/categories/tips/_index.md b/content/categories/tips/_index.md new file mode 100644 index 0000000..f09acf1 --- /dev/null +++ b/content/categories/tips/_index.md @@ -0,0 +1,5 @@ +--- +title: Tips +description: > + I learned something the hard way so that you wouldn't have to. +--- \ No newline at end of file diff --git a/content/categories/vmware/_index.md b/content/categories/vmware/_index.md new file mode 100644 index 0000000..88779b0 --- /dev/null +++ b/content/categories/vmware/_index.md @@ -0,0 +1,4 @@ +--- +title: "VMware" +description: "vSphere, vCenter, vRealize, vTanzu, vBroadcom..." +--- \ No newline at end of file diff --git a/content/posts/3d-modeling-and-printing-on-chrome-os/index.md b/content/posts/3d-modeling-and-printing-on-chrome-os/index.md index c876383..6b121aa 100644 --- a/content/posts/3d-modeling-and-printing-on-chrome-os/index.md +++ b/content/posts/3d-modeling-and-printing-on-chrome-os/index.md @@ -3,6 +3,7 @@ date: "2020-09-14T08:34:30Z" thumbnail: qDTXt1jp3.png featureImage: qDTXt1jp3.png usePageBundles: true +categories: ChromeOS tags: - linux - chromeos @@ -18,12 +19,12 @@ That's a pretty sweet setup, but I still needed a way to convert STL 3D models i Enter "Crostini," Chrome OS's [Linux (Beta) feature](https://chromium.googlesource.com/chromiumos/docs/+/master/containers_and_vms.md). It consists of a hardened Linux VM named `termina` which runs (by default) a Debian Buster LXD container named `penguin` (though you can spin up just about any container for which you can find an [image](https://us.images.linuxcontainers.org/)) and some fancy plumbing to let Chrome OS and Linux interact in specific clearly-defined ways. It's a brilliant balance between offering the flexibility of Linux while preserving Chrome OS's industry-leading security posture. -![Neofetch in the Crostini terminal](lhTnVwCO3.png) +![Screenshot of the 'neofetch' utility](lhTnVwCO3.png) There are plenty of great guides (like [this one](https://www.computerworld.com/article/3314739/linux-apps-on-chrome-os-an-easy-to-follow-guide.html)) on how to get started with Linux on Chrome OS so I won't rehash those steps here. One additional step you will probably want to take is make sure that your Chromebook is configured to enable hyperthreading, as it may have [hyperthreading disabled by default](https://support.google.com/chromebook/answer/9340236). Just plug `chrome://flags/#scheduler-configuration` into Chrome's address bar, set it to `Enables Hyper-Threading on relevant CPUs`, and then click the button to restart your Chromebook. You'll thank me later. -![Enabling hyperthreading](LHax6lAwh.png) +![Screenshot of ChromeOS flags page showing that '#scheduler-configuration' is set to 'Enables Hyper-Threading on relevant CPUs](LHax6lAwh.png) ### The Software I settled on using [FreeCAD](https://www.freecadweb.org/) for parametric modeling and [Ultimaker Cura](https://ultimaker.com/software/ultimaker-cura) for my GCODE slicer, but unfortunately getting them working cleanly wasn't entirely straightforward. @@ -68,7 +69,7 @@ Comment[de_DE]=Feature-basierter parametrischer Modellierer MimeType=application/x-extension-fcstd ``` That's it! Get on with your 3D-modeling bad self. -![FreeCAD](qDTXt1jp3.png) +![Screenshot of FreeCAD showing a 3d model being worked on](qDTXt1jp3.png) Now that you've got a model, be sure to [export it as an STL mesh](https://wiki.freecadweb.org/Export_to_STL_or_OBJ) so you can import it into your slicer. #### Ultimaker Cura @@ -88,12 +89,12 @@ sudo apt update && sudo apt install menulibre # [tl! .cmd:2] menulibre ``` Just plug in the relevant details (you can grab the appropriate icon [here](https://github.com/Ultimaker/Cura/blob/master/icons/cura-128.png)), hit the filing cabinet Save icon, and you should then be able to search for Cura from the Chrome OS launcher. -![Using menulibre to create the launcher shortcut](VTISYOKHO.png) +![Screenshot demoing the use of 'menulibre' to create the launcher shortcut](VTISYOKHO.png) -![Ultimaker Cura](f8nRJcyI6.png) +![Screenshot of Ultimake Cura software](f8nRJcyI6.png) From there, just import the STL mesh, configure the appropriate settings, slice, and save the resulting GCODE. You can then just upload the GCODE straight to The Spaghetti Detective and kick off the print. -![Successful print, designed and sliced on Chrome OS!](2g57odtq2.jpeg) +![A 3d-printed adapter for mounting a rear reflector on a bicycle, designed, sliced, and printed from a Chromebook](2g57odtq2.jpeg) Nice! \ No newline at end of file diff --git a/content/posts/abusing-chromes-custom-search-engines-for-fun-and-profit/index.md b/content/posts/abusing-chromes-custom-search-engines-for-fun-and-profit/index.md index d3ceca0..5c7ba19 100644 --- a/content/posts/abusing-chromes-custom-search-engines-for-fun-and-profit/index.md +++ b/content/posts/abusing-chromes-custom-search-engines-for-fun-and-profit/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: Tips date: "2020-09-24T08:34:30Z" thumbnail: fmLDUWjia.png usePageBundles: true @@ -17,7 +17,7 @@ Point your browser to `chrome://settings/searchEngines` to see which sites are r Each of these search engine entries has three parts: a name ("Search engine"), a Keyword, and a Query URL. The "Search engine" title is just what will appear in the Omnibox when the search engine gets triggered, the Keyword is what you'll type in the Omnibox to trigger it, and the Query URL tells Chrome how to handle the search. All you have to do is type the keyword, hit your Tab key to activate the search, input your query, and hit Enter: ![Using a custom search engine](o_o7rt4pA.gif) -For sites which register themselves automatically, the keyword is often set to something like `domain.tld` so it might make sense to assign it as something shorter or more descriptive. +For sites which register themselves automatically, the keyword is often set to something like `domain.tld` so it might make sense to assign it as something shorter or more descriptive. The Query URL is basically just what appears in the address bar when you search the site directly, with `%s` placed where your query text would normally go. You can view these details for a given search entry by tapping the three-dot menu button and selecting "Edit", and you can manually create new entries by hitting that big friendly "Add" button: ![Editing a search engine](fmLDUWjia.png) @@ -55,7 +55,7 @@ This works for pretty much any site which parses the URL to render certain conte Your Query URL doesn't even need to include a query at all! You can use the Custom Search Engines as a sort of hyper-fast shortcut to pages you visit frequently. If I create a new entry with the Keyword `searchax` and `abusing-chromes-custom-search-engines-for-fun-and-profit` as the query URL, I can quickly open to this page by typing `searchax[tab][enter]`: ![Custom search shortener](YilNCaHil.png) -I use that trick pretty regularly for getting back to vCenter appliance management interfaces without having to type out the full FQDN and port number and all that. +I use that trick pretty regularly for getting back to vCenter appliance management interfaces without having to type out the full FQDN and port number and all that. ------ diff --git a/content/posts/adding-vm-notes-and-custom-attributes-with-vra8/index.md b/content/posts/adding-vm-notes-and-custom-attributes-with-vra8/index.md index 2492b92..099f069 100644 --- a/content/posts/adding-vm-notes-and-custom-attributes-with-vra8/index.md +++ b/content/posts/adding-vm-notes-and-custom-attributes-with-vra8/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-06-01T08:34:30Z" thumbnail: -Fuvz-GmF.png usePageBundles: true @@ -11,7 +11,7 @@ tags: title: Adding VM Notes and Custom Attributes with vRA8 --- -*In [past posts](/series/vra8), I started by [creating a basic deployment infrastructure](/vra8-custom-provisioning-part-one) in Cloud Assembly and using tags to group those resources. I then [wrote an integration](/integrating-phpipam-with-vrealize-automation-8) to let vRA8 use phpIPAM for static address assignments. I [implemented a vRO workflow](/vra8-custom-provisioning-part-two) for generating unique VM names which fit an organization's established naming standard, and then [extended the workflow](/vra8-custom-provisioning-part-three) to avoid any naming conflicts in Active Directory and DNS. And, finally, I [created an intelligent provisioning request form in Service Broker](/vra8-custom-provisioning-part-four) to make it easy for users to get the servers they need. That's got the core functionality pretty well sorted, so moving forward I'll be detailing additions that enable new capabilities and enhance the experience.* +*In [past posts](/categories/vmware), I started by [creating a basic deployment infrastructure](/vra8-custom-provisioning-part-one) in Cloud Assembly and using tags to group those resources. I then [wrote an integration](/integrating-phpipam-with-vrealize-automation-8) to let vRA8 use phpIPAM for static address assignments. I [implemented a vRO workflow](/vra8-custom-provisioning-part-two) for generating unique VM names which fit an organization's established naming standard, and then [extended the workflow](/vra8-custom-provisioning-part-three) to avoid any naming conflicts in Active Directory and DNS. And, finally, I [created an intelligent provisioning request form in Service Broker](/vra8-custom-provisioning-part-four) to make it easy for users to get the servers they need. That's got the core functionality pretty well sorted, so moving forward I'll be detailing additions that enable new capabilities and enhance the experience.* In this post, I'll describe how to get certain details from the Service Broker request form and into the VM's properties in vCenter. The obvious application of this is adding descriptive notes so I can remember what purpose a VM serves, but I will also be using [Custom Attributes](https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vcenterhost.doc/GUID-73606C4C-763C-4E27-A1DA-032E4C46219D.html) to store the server's Point of Contact information and a record of which ticketing system request resulted in the server's creation. diff --git a/content/posts/adguard-home-in-docker-on-photon-os/index.md b/content/posts/adguard-home-in-docker-on-photon-os/index.md index e6aafb7..a1f0ddf 100644 --- a/content/posts/adguard-home-in-docker-on-photon-os/index.md +++ b/content/posts/adguard-home-in-docker-on-photon-os/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Self-Hosting date: "2021-05-27T08:34:30Z" thumbnail: HRRpFOKuN.png usePageBundles: true diff --git a/content/posts/auto-connect-to-protonvpn-on-untrusted-wifi-with-tasker/index.md b/content/posts/auto-connect-to-protonvpn-on-untrusted-wifi-with-tasker/index.md index e6ec022..4dbd640 100644 --- a/content/posts/auto-connect-to-protonvpn-on-untrusted-wifi-with-tasker/index.md +++ b/content/posts/auto-connect-to-protonvpn-on-untrusted-wifi-with-tasker/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Code date: "2020-11-24T08:34:30Z" lastmod: "2021-03-12" thumbnail: Ki7jo65t3.png @@ -37,7 +37,7 @@ It's important to use the [open-source](https://github.com/schwabe/ics-openvpn) ### OpenVPN config file You can find instructions for configuring the OpenVPN client to work with ProtonVPN [here](https://protonvpn.com/support/android-vpn-setup/) but I'll go ahead and hit the highlights. You'll probably want to go ahead and do all this from your phone so you don't have to fuss with transferring files around, but hey, *you do you*. -1. Log in to your ProtonVPN account (or sign up for a new free one) at https://account.protonvpn.com/login. +1. Log in to your ProtonVPN account (or sign up for a new free one) at https://account.protonvpn.com/login. 2. Use the panel on the left side to navigate to **[Downloads > OpenVPN configuration files](https://account.protonvpn.com/downloads#openvpn-configuration-files)**. 3. Select the **Android** platform and **UDP** as the protocol, unless you have a [particular reason to use TCP](https://protonvpn.com/support/udp-tcp/#:~:text=When%20to%20use%20UDP%20vs.%20TCP). 4. Select and download the desired config file: @@ -49,7 +49,7 @@ You can find instructions for configuring the OpenVPN client to work with Proton Feel free to download more than one if you'd like to have different profiles available within the OpenVPN app. -ProtonVPN automatically generates a set of user credentials to use with a third-party VPN client so that you don't have to share your personal creds. You'll want to make a note of that randomly-generated username and password so you can plug them in to the OpenVPN app later. You can find the details at **[Account > OpenVPN / IKEv2 username](https://account.protonvpn.com/account#openvpn)**. +ProtonVPN automatically generates a set of user credentials to use with a third-party VPN client so that you don't have to share your personal creds. You'll want to make a note of that randomly-generated username and password so you can plug them in to the OpenVPN app later. You can find the details at **[Account > OpenVPN / IKEv2 username](https://account.protonvpn.com/account#openvpn)**. **Now that you've got the profile file, skip on down to [The Update](#update) to import it into OpenVPN Connect.** @@ -67,7 +67,7 @@ Now what you've got the config file(s) and your client credentials, it's time to Success! -I don't like to have a bunch of persistent notification icons hanging around (and Android already shows a persistent status icon when a VPN connection is active). If you're like me, long-press the OpenVPN notification and tap the gear icon. Then tap on the **Connection statistics** category and activate the **Minimized** slider. The notification will still appear, but it will collapse to the bottom of your notification stack and you won't get bugged by the icon. +I don't like to have a bunch of persistent notification icons hanging around (and Android already shows a persistent status icon when a VPN connection is active). If you're like me, long-press the OpenVPN notification and tap the gear icon. Then tap on the **Connection statistics** category and activate the **Minimized** slider. The notification will still appear, but it will collapse to the bottom of your notification stack and you won't get bugged by the icon. ![Notification settings](WWuHwVvrk.png) @@ -76,21 +76,21 @@ Open up Tasker and get ready to automate! We're going to wind up with at least t Let's start with a profile to track whether or not we're connected to one of our preferred/trusted WiFi networks: -#### Trusted WiFi +#### Trusted WiFi 1. Tap the '+' sign to create a new profile, and add a new **State > Net > Wifi Connected** context. This profile will become active whenever your phone connects to WiFi. 2. Tap the magnifying glass next to the **SSID** field, which will pop up a list of all detected nearby network identifiers. Tap to select whichever network(s) you'd like to be considered "safe". You can also manually enter the SSID names, separating multiple options with a `/` (ex, `FBI Surveillance Van/TellMyWifiLoveHer/Pretty fly for a WiFi`). Or, for more security, identify the networks based on the MACs instead of the SSIDs - just be sure to capture the MACs for any extenders or mesh nodes too! -3. Once you've got your networks added, tap the back button to move *forward* to the next task (Ah, Android!): configuring the *action* which will occur when the context is satisfied. -4. Tap the **New Task** option and then tap the check mark to skip giving it a name (no need). +3. Once you've got your networks added, tap the back button to move *forward* to the next task (Ah, Android!): configuring the *action* which will occur when the context is satisfied. +4. Tap the **New Task** option and then tap the check mark to skip giving it a name (no need). 5. Hit the '+' button to add an action and select **Variables > Variable Set**. -6. For **Name**, enter `%TRUSTED_WIFI` (all caps to make it a "public" variable), and for the **To** field just enter `1`. -7. Hit back to save the action, and back again to save the profile. +6. For **Name**, enter `%TRUSTED_WIFI` (all caps to make it a "public" variable), and for the **To** field just enter `1`. +7. Hit back to save the action, and back again to save the profile. 8. Back at the profile list, long-press on the **Variable Set...** action and then select **Add Exit Task**. 9. We want to un-set the variable when no longer connected to a trusted WiFi network so add a new **Variables > Variable Clear** action and set the name to `%TRUSTED_WIFI`. 10. And back back out to admire your handiwork. Here's a recap of the profile: ``` Profile: Trusted Wifi State: Wifi Connected [ SSID:FBI Surveillance Van/TellMyWifiLoveHer/Pretty fly for a WiFi MAC:* IP:* Active:Any ] -Enter: Anon +Enter: Anon A1: Variable Set [ Name:%TRUSTED_WIFI To:1 Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:0 ] Exit: Anon A1: Variable Clear [ Name:%TRUSTED_WIFI Pattern Matching:Off Local Variables Only:Off Clear All Variables:Off ] @@ -103,7 +103,7 @@ This profile will kick in if the phone connects to a WiFi network which isn't on 1. It starts out the same way by creating a new profile with the **State > Net > Wifi Connected** context but this time don't add any network names to the list. 2. For the action, select **Plugin > OpenVpn Tasker Plugin**, tap the pencil icon to edit the configuration, and select your VPN profile from the list under **Connect using profile** 3. Back at the Action Edit screen, tap the checkbox next to **If** and enter the variable name `%TRUSTED_WIFI`. Tap the '~' button to change the condition operator to **Isn't Set**. So while this profile will activate every time you connect to WiFi, the action which connects to the VPN will only fire if the WiFi isn't a trusted network. -4. Back out to the profile list and add a new Exit Task. +4. Back out to the profile list and add a new Exit Task. 5. Add another **Plugin > OpenVpn Tasker Plugin** task and this time configure it to **Disconnect VPN**. To recap: @@ -149,7 +149,7 @@ After installing and launching the official [OpenVPN Connect app](https://play.g ![Creating a profile in OpenVPN Connect](KjGOX8Yiv.png) #### Tasker profiles -Go ahead and create the [Trusted Wifi profile](#trusted-wifi) as described above. +Go ahead and create the [Trusted Wifi profile](#trusted-wifi) as described above. The condition for the [VPN on Strange Wifi profile](#vpn-on-strange-wifi) will be the same, but the task will be different. This time, add a **System > Send Intent** action. You'll need to enter the following details, leaving the other fields blank/default: @@ -176,4 +176,4 @@ Class: net.openvpn.unified.MainActivity Target: Activity ``` -All set! You can pop back up to the [Epilogue](#epilogue-working-with-googles-vpn) section to continue tweaking to avoid conflicts with Google's auto-connect VPN if you'd like. \ No newline at end of file +All set! You can pop back up to the [Epilogue](#epilogue-working-with-googles-vpn) section to continue tweaking to avoid conflicts with Google's auto-connect VPN if you'd like. \ No newline at end of file diff --git a/content/posts/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk/index.md b/content/posts/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk/index.md index 6e5a1bf..41b276a 100644 --- a/content/posts/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk/index.md +++ b/content/posts/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk/index.md @@ -1,5 +1,5 @@ --- -series: Code +categories: Code date: "2021-04-29T08:34:30Z" usePageBundles: true thumbnail: 20210723-script.png @@ -11,7 +11,7 @@ title: Automatic unattended expansion of Linux root LVM volume to fill disk toc: false --- -While working on my [vRealize Automation 8 project](/series/vra8), I wanted to let users specify how large a VM's system drive should be and have vRA apply that without any further user intervention. For instance, if the template has a 60GB C: drive and the user specifies that they want it to be 80GB, vRA will embiggen the new VM's VMDK to 80GB and then expand the guest file system to fill up the new free space. +While working on my [vRealize Automation 8 project](/categories/vmware), I wanted to let users specify how large a VM's system drive should be and have vRA apply that without any further user intervention. For instance, if the template has a 60GB C: drive and the user specifies that they want it to be 80GB, vRA will embiggen the new VM's VMDK to 80GB and then expand the guest file system to fill up the new free space. I'll get into the details of how that's implemented from the vRA side #soon, but first I needed to come up with simple scripts to extend the guest file system to fill the disk. diff --git a/content/posts/automating-camera-notifications-home-assistant-ntfy/index.md b/content/posts/automating-camera-notifications-home-assistant-ntfy/index.md index 33c72e1..0e7073f 100644 --- a/content/posts/automating-camera-notifications-home-assistant-ntfy/index.md +++ b/content/posts/automating-camera-notifications-home-assistant-ntfy/index.md @@ -1,14 +1,14 @@ --- title: "Automating Security Camera Notifications With Home Assistant and Ntfy" date: 2023-11-25 -lastmod: 2023-11-27 +lastmod: 2024-01-15 description: "Using the power of Home Assistant automations and Ntfy push notifications to level-up security camera motion detections." featured: true alias: automating-security-camera-notifications-with-home-assistant-and-ntfy toc: true comments: true thumbnail: thumbnail.png -series: Projects +categories: Self-Hosting tags: - api - automation @@ -25,7 +25,7 @@ I figured I could combine the excellent [Reolink integration for Home Assistant] ### Alert on motion detection {{% notice note "Ntfy Integration" %}} -Since manually configuring ntfy in Home Assistant via the [RESTful Notifications integration](easy-push-notifications-with-ntfy/#notify-configuration), I found that a [ntfy-specific integration](https://github.com/ivanmihov/homeassistant-ntfy.sh) was available through the [Home Assistant Community Store](https://hacs.xyz/) addon. That setup is a bit more flexible so I've switched my setup to use it instead: +Since manually configuring ntfy in Home Assistant via the [RESTful Notifications integration](/easy-push-notifications-with-ntfy#notify-configuration), I found that a [ntfy-specific integration](https://github.com/ivanmihov/homeassistant-ntfy.sh) was available through the [Home Assistant Community Store](https://hacs.xyz/) addon. That setup is a bit more flexible so I've switched my setup to use it instead: ```yaml # configuration.yaml notify: diff --git a/content/posts/bitwarden-password-manager-self-hosted-on-free-google-cloud-instance/index.md b/content/posts/bitwarden-password-manager-self-hosted-on-free-google-cloud-instance/index.md index 59b6d6b..2b8c5d2 100644 --- a/content/posts/bitwarden-password-manager-self-hosted-on-free-google-cloud-instance/index.md +++ b/content/posts/bitwarden-password-manager-self-hosted-on-free-google-cloud-instance/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Self-Hosting date: "2018-09-26T08:34:30Z" lastmod: "2022-03-06" thumbnail: i0UKdXleC.png diff --git a/content/posts/bulk-import-vsphere-dvportgroups-to-phpipam/index.md b/content/posts/bulk-import-vsphere-dvportgroups-to-phpipam/index.md index 0ab3752..4cb8e3b 100644 --- a/content/posts/bulk-import-vsphere-dvportgroups-to-phpipam/index.md +++ b/content/posts/bulk-import-vsphere-dvportgroups-to-phpipam/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "code.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Code +categories: Code tags: - vmware - powercli diff --git a/content/posts/burn-an-iso-to-usb-with-the-chromebook-recovery-utility/index.md b/content/posts/burn-an-iso-to-usb-with-the-chromebook-recovery-utility/index.md index 3a97c42..631d613 100644 --- a/content/posts/burn-an-iso-to-usb-with-the-chromebook-recovery-utility/index.md +++ b/content/posts/burn-an-iso-to-usb-with-the-chromebook-recovery-utility/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: ChromeOS date: "2020-12-23T08:34:30Z" thumbnail: -lp1-DGiM.png usePageBundles: true diff --git a/content/posts/cat-file-without-comments/index.md b/content/posts/cat-file-without-comments/index.md index 4043737..a0796e1 100644 --- a/content/posts/cat-file-without-comments/index.md +++ b/content/posts/cat-file-without-comments/index.md @@ -14,7 +14,7 @@ usePageBundles: true # thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8, K8s on vSphere +categories: Tips # Projects, Code, vRA8, K8s on vSphere tags: - linux - shell diff --git a/content/posts/cloud-based-wireguard-vpn-remote-homelab-access/index.md b/content/posts/cloud-based-wireguard-vpn-remote-homelab-access/index.md index 0cb2f24..794d8ef 100644 --- a/content/posts/cloud-based-wireguard-vpn-remote-homelab-access/index.md +++ b/content/posts/cloud-based-wireguard-vpn-remote-homelab-access/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Self-Hosting date: "2021-10-28T00:00:00Z" thumbnail: 20211028_wireguard_in_the_cloud.jpg usePageBundles: true diff --git a/content/posts/create-vms-chromebook-hashicorp-vagrant/index.md b/content/posts/create-vms-chromebook-hashicorp-vagrant/index.md index 3526ee6..c1dd764 100644 --- a/content/posts/create-vms-chromebook-hashicorp-vagrant/index.md +++ b/content/posts/create-vms-chromebook-hashicorp-vagrant/index.md @@ -1,7 +1,7 @@ --- title: "Create Virtual Machines on a Chromebook with HashiCorp Vagrant" # Title of the blog post. date: 2023-02-20 # Date of post creation. -lastmod: 2023-02-25 +lastmod: 2024-01-17 description: "Pairing the powerful Linux Development Environment on modern Chromebooks with HashiCorp Vagrant to create and manage local virtual machines for development and testing" # Description used for search engine. featured: true # Sets if post is a featured post, making appear on the home page side bar. draft: false # Sets whether to render this page. Draft of true will not be rendered. @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects +categories: ChromeOS tags: - linux - chromeos @@ -57,6 +57,16 @@ echo "remember_owner = 0" | sudo tee -a /etc/libvirt/qemu.conf # [tl! .cmd:1] sudo systemctl restart libvirtd ``` +{{% notice note "Update 2024-01-17" %}} +There seems to be an [issue with libvirt in LXC containers on Debian Bookworm](https://gitlab.com/libvirt/libvirt/-/issues/556), which explains why I was getting errors on `vagrant up` after updating my Crostini environment. + +The workaround is to add another line to `qemu.conf`: +```shell +echo "namespaces = []" | sudo tee -a /etc/libvirt/qemu.conf # [tl! .cmd:1] +sudo systemctl restart libvirtd +``` +{{% /notice %}} + I'm also going to use `rsync` to share a [synced folder](https://developer.hashicorp.com/vagrant/docs/synced-folders/basic_usage) between the host and the VM guest so I'll need to make sure that's installed too: ```shell sudo apt install rsync # [tl! .cmd] diff --git a/content/posts/creating-static-records-in-microsoft-dns-from-vrealize-automation/index.md b/content/posts/creating-static-records-in-microsoft-dns-from-vrealize-automation/index.md index fddb128..3ff90b0 100644 --- a/content/posts/creating-static-records-in-microsoft-dns-from-vrealize-automation/index.md +++ b/content/posts/creating-static-records-in-microsoft-dns-from-vrealize-automation/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-08-13T00:00:00Z" lastmod: "2022-01-18" usePageBundles: true diff --git a/content/posts/ditching-vsphere-for-proxmox/index.md b/content/posts/ditching-vsphere-for-proxmox/index.md index 33f1ac6..0b5d2eb 100644 --- a/content/posts/ditching-vsphere-for-proxmox/index.md +++ b/content/posts/ditching-vsphere-for-proxmox/index.md @@ -5,7 +5,7 @@ description: "I moved my homelab from VMware vSphere to Proxmox VE, and my only featured: false toc: true comments: true -series: Tips # Projects, Code +categories: Tips # Projects, Code tags: - homelab - linux diff --git a/content/posts/docker-on-windows-10-with-wsl2/index.md b/content/posts/docker-on-windows-10-with-wsl2/index.md index 560975b..539167f 100644 --- a/content/posts/docker-on-windows-10-with-wsl2/index.md +++ b/content/posts/docker-on-windows-10-with-wsl2/index.md @@ -2,6 +2,7 @@ date: "2020-09-22T08:34:30Z" thumbnail: 8p-PSHx1R.png usePageBundles: true +categories: Tips tags: - docker - windows diff --git a/content/posts/easy-push-notifications-with-ntfy/index.md b/content/posts/easy-push-notifications-with-ntfy/index.md index 6be35c6..fb11bb9 100644 --- a/content/posts/easy-push-notifications-with-ntfy/index.md +++ b/content/posts/easy-push-notifications-with-ntfy/index.md @@ -6,7 +6,7 @@ description: "Deploying and configuring a self-hosted pub-sub notification handl featured: false toc: true comments: true -series: Projects +categories: Self-Hosting tags: - android - api diff --git a/content/posts/enable-fips-fix-aria-lifecycle/index.md b/content/posts/enable-fips-fix-aria-lifecycle/index.md new file mode 100644 index 0000000..0adcec9 --- /dev/null +++ b/content/posts/enable-fips-fix-aria-lifecycle/index.md @@ -0,0 +1,46 @@ +--- +title: "Enabling FIPS Compliance Fixes Aria Lifecycle 8.14" +date: 2024-01-19 +# lastmod: 2024-01-19 +description: "Never in my life have I seen enabling FIPS *fix* a problem - until now." +featured: false +comments: true +categories: VMware +tags: + - vmware +--- +This week, VMware posted [VMSA-2024-0001](https://www.vmware.com/security/advisories/VMSA-2024-0001.html) which details a critical (9.9/10) vulnerability in vRealize *Aria* Automation. While working to get our environment patched, I ran into an interesting error on our Aria Lifecycle appliance: + +```log +Error Code: LCMVRAVACONFIG590024 +VMware Aria Automation hostname is not valid or unable to run the product specific commands via SSH on the host. Check if VMware Aria Automation is up and running. +VMware Aria Automation hostname is not valid or unable to run the product specific commands via SSH on the host. Check if VMware Aria Automation is up and running. +com.vmware.vrealize.lcm.drivers.vra80.exception.VraVaProductNotFoundException: Either provided hostname: is not a valid VMware Aria Automation hostname or unable to run the product specific commands via SSH on the host. + at com.vmware.vrealize.lcm.drivers.vra80.helpers.VraPreludeInstallHelper.getVraFullVersion(VraPreludeInstallHelper.java:970) + at com.vmware.vrealize.lcm.drivers.vra80.helpers.VraPreludeInstallHelper.checkVraApplianceAndVersion(VraPreludeInstallHelper.java:978) + at com.vmware.vrealize.lcm.drivers.vra80.helpers.VraPreludeInstallHelper.getVraProductDetails(VraPreludeInstallHelper.java:754) + at com.vmware.vrealize.lcm.plugin.core.vra80.task.VraVaImportEnvironmentTask.execute(VraVaImportEnvironmentTask.java:145) + at com.vmware.vrealize.lcm.platform.automata.service.Task.retry(Task.java:158) + at com.vmware.vrealize.lcm.automata.core.TaskThread.run(TaskThread.java:60) + at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + at java.base/java.lang.Thread.run(Unknown Source) +``` + +Digging further into the appliance logs revealed some more details: +```log +Session.connect: java.security.spec.InvalidKeySpecException: key spec not recognized +``` + +That seems like a much more insightful error than "the hostname is not valid, dummy." + +Anyhoo, searching for the error took me to a VMware KB on the subject: +- [VMware Aria Suite Lifecycle 8.14 Patch 1 Day 2 operations fail for VMware Aria Automation with error code LCMVRAVACONFIG590024 (96243)](https://kb.vmware.com/s/article/96243) + +> After applying VMware Aria Suite Lifecycle 8.14 Patch 1, you may encounter deployment and day-2 operation failures, attributed to the elimination of weak algorithms in Suite Lifecycle. To prevent such issues, it is recommended to either turn on FIPS in VMware Aria Suite Lifecycle or implement the specified workarounds on other VMware Aria Products, as outlined in the article Steps for Removing SHA1 weak Algorithms/Ciphers from all VMware Aria Products. + +That's right. According to the KB, the solution for the untrusted encryption algorithms is to *enable* FIPS compliance. I was skeptical: I've never seen FIPS enforcement fix problems, it always causes them. + +But I gave it a shot, and *holy crap it actually worked!* Enabling FIPS compliance on the Aria Lifecycle appliance got things going again. + +I feel like I've seen everything now. \ No newline at end of file diff --git a/content/posts/enable-tanzu-cli-auto-completion-bash-zsh/index.md b/content/posts/enable-tanzu-cli-auto-completion-bash-zsh/index.md index 6ad851f..c28a02d 100644 --- a/content/posts/enable-tanzu-cli-auto-completion-bash-zsh/index.md +++ b/content/posts/enable-tanzu-cli-auto-completion-bash-zsh/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "tanzu-completion.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips +categories: VMware tags: - vmware - linux diff --git a/content/posts/esxi-arm-on-quartz64/index.md b/content/posts/esxi-arm-on-quartz64/index.md index bdec745..b65b640 100644 --- a/content/posts/esxi-arm-on-quartz64/index.md +++ b/content/posts/esxi-arm-on-quartz64/index.md @@ -14,7 +14,7 @@ featureImage: "quartz64.jpg" # Sets featured image on blog post. thumbnail: "quartz64.jpg" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects +categories: VMware tags: - vmware - linux diff --git a/content/posts/federated-matrix-server-synapse-on-oracle-clouds-free-tier/index.md b/content/posts/federated-matrix-server-synapse-on-oracle-clouds-free-tier/index.md index 1a90093..033e516 100644 --- a/content/posts/federated-matrix-server-synapse-on-oracle-clouds-free-tier/index.md +++ b/content/posts/federated-matrix-server-synapse-on-oracle-clouds-free-tier/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Self-Hosting date: "2021-06-28T00:00:00Z" thumbnail: 2xe34VJym.png usePageBundles: true diff --git a/content/posts/finding-the-most-popular-ips-in-a-log-file/index.md b/content/posts/finding-the-most-popular-ips-in-a-log-file/index.md index c51ba1d..cb22105 100644 --- a/content/posts/finding-the-most-popular-ips-in-a-log-file/index.md +++ b/content/posts/finding-the-most-popular-ips-in-a-log-file/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: Tips date: "2020-09-13T08:34:30Z" usePageBundles: true tags: diff --git a/content/posts/fixing-403-error-ssc-8-6-vra-idm/index.md b/content/posts/fixing-403-error-ssc-8-6-vra-idm/index.md index 6e16f21..40434fe 100644 --- a/content/posts/fixing-403-error-ssc-8-6-vra-idm/index.md +++ b/content/posts/fixing-403-error-ssc-8-6-vra-idm/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-11-05T00:00:00Z" thumbnail: 20211105_ssc_403.png usePageBundles: true diff --git a/content/posts/fixing-wsl2-connectivity-when-connected-to-a-vpn-with-wsl-vpnkit/index.md b/content/posts/fixing-wsl2-connectivity-when-connected-to-a-vpn-with-wsl-vpnkit/index.md index c09df0e..9b819e3 100644 --- a/content/posts/fixing-wsl2-connectivity-when-connected-to-a-vpn-with-wsl-vpnkit/index.md +++ b/content/posts/fixing-wsl2-connectivity-when-connected-to-a-vpn-with-wsl-vpnkit/index.md @@ -2,6 +2,7 @@ date: "2020-10-07T08:34:30Z" thumbnail: MnmMuA0HC.png usePageBundles: true +categories: Tips tags: - windows - linux @@ -11,15 +12,15 @@ title: Fixing WSL2 connectivity when connected to a VPN with wsl-vpnkit toc: false --- -I was pretty excited to get [WSL2 and Docker working on my Windows 10 1909](/docker-on-windows-10-with-wsl2) laptop a few weeks ago, but I quickly encountered a problem: WSL2 had no network connectivity when connected to my work VPN. +I was pretty excited to get [WSL2 and Docker working on my Windows 10 1909](/docker-on-windows-10-with-wsl2) laptop a few weeks ago, but I quickly encountered a problem: WSL2 had no network connectivity when connected to my work VPN. Well, that's not *entirely* true; Docker worked just fine, but nothing else could talk to anything outside of the WSL environment. I found a few open issues for this problem in the [WSL2 Github](https://github.com/microsoft/WSL/issues?q=is%3Aissue+is%3Aopen+VPN) with suggested workarounds including modifying Windows registry entries, adjusting the metrics assigned to various virtual network interfaces within Windows, and manually setting DNS servers in `/etc/resolv.conf`. None of these worked for me. I eventually came across a solution [here](https://github.com/sakai135/wsl-vpnkit) which did the trick. This takes advantage of the fact that Docker for Windows is already utilizing `vpnkit` for connectivity - so you may also want to be sure Docker Desktop is configured to start at login. -The instructions worked well for me so I won't rehash them all here. When it came time to modify my `/etc/resolv.conf` file, I added in two of the internal DNS servers followed by the IP for my home router's DNS service. This allows me to use WSL2 both on and off the corporate network without having to reconfigure things. +The instructions worked well for me so I won't rehash them all here. When it came time to modify my `/etc/resolv.conf` file, I added in two of the internal DNS servers followed by the IP for my home router's DNS service. This allows me to use WSL2 both on and off the corporate network without having to reconfigure things. -All I need to do now is execute `sudo ./wsl-vpnkit` and leave that running in the background when I need to use WSL while connected to the corporate VPN. +All I need to do now is execute `sudo ./wsl-vpnkit` and leave that running in the background when I need to use WSL while connected to the corporate VPN. ![Successful connection via wsl-vpnkit](MnmMuA0HC.png) diff --git a/content/posts/free-serverless-url-shortener-google-cloud-run/index.md b/content/posts/free-serverless-url-shortener-google-cloud-run/index.md index 731362c..7280b01 100644 --- a/content/posts/free-serverless-url-shortener-google-cloud-run/index.md +++ b/content/posts/free-serverless-url-shortener-google-cloud-run/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Self-Hosting date: "2021-08-20T00:00:00Z" lastmod: 2022-02-03 usePageBundles: true diff --git a/content/posts/getting-started-vra-rest-api/index.md b/content/posts/getting-started-vra-rest-api/index.md index 0c076ec..650d519 100644 --- a/content/posts/getting-started-vra-rest-api/index.md +++ b/content/posts/getting-started-vra-rest-api/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: vRA8 # Projects, Code, vRA8 +categories: VMware # Projects, Code, vRA8 tags: - vmware - vra @@ -312,7 +312,7 @@ This doesn't give me the *name* of the regions, but I could use the `_links.regi You'll notice that HTTPie also prettifies the JSON response to make it easy for humans to parse. This is great for experimenting with requests against different API endpoints and getting a feel for what data can be found where. And firing off tests in HTTPie can be a lot quicker (and easier to format) than with other tools. Now let's take what we've learned and see about implementing it as vRO actions. -[^pie]: ![](pie.gif) +[^pie]: ![GIF from Supernatural wherein Dean ogles some delicious pie.](pie.gif) [^token]: Well, most of it. [^foreshadowing]: That knowledge will come in handy later. ### vRealize Orchestrator actions diff --git a/content/posts/gitea-self-hosted-git-server/index.md b/content/posts/gitea-self-hosted-git-server/index.md index 143dc96..8f526cc 100644 --- a/content/posts/gitea-self-hosted-git-server/index.md +++ b/content/posts/gitea-self-hosted-git-server/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "gitea-logo.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects +categories: Self-Hosting tags: - caddy - linux diff --git a/content/posts/hello-hugo/index.md b/content/posts/hello-hugo/index.md index 3820f97..7468624 100644 --- a/content/posts/hello-hugo/index.md +++ b/content/posts/hello-hugo/index.md @@ -16,6 +16,7 @@ shareImage: "/hugo-logo-wide.png" # shareImage: "/images/path/share.png" # Designate a separate image for social media sharing. codeMaxLines: 10 # Override global value for how many lines within a code block before auto-collapsing. codeLineNumbers: false # Override global value for showing of line numbers within code block. +categories: Backstage tags: - meta - hugo diff --git a/content/posts/how-to-ask-for-help/index.md b/content/posts/how-to-ask-for-help/index.md index f628455..3ad2a51 100644 --- a/content/posts/how-to-ask-for-help/index.md +++ b/content/posts/how-to-ask-for-help/index.md @@ -6,7 +6,7 @@ timeless: true description: There are no dumb questions - but there are smarter (and dumber) ways to ask them. featured: true aliases: ["how2ask"] -series: Tips +categories: Tips --- I spend a lot of my time and energy answering technical questions, both professionally and "for fun" as a way to scratch that troubleshooting itch. How a question is asked plays a big factor in how effectively I'll be able to answer it. diff --git a/content/posts/integrating-phpipam-with-vrealize-automation-8/index.md b/content/posts/integrating-phpipam-with-vrealize-automation-8/index.md index a8e0a03..5ee1a8b 100644 --- a/content/posts/integrating-phpipam-with-vrealize-automation-8/index.md +++ b/content/posts/integrating-phpipam-with-vrealize-automation-8/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-02-22T08:34:30Z" lastmod: 2022-07-25 thumbnail: 7_QI-Ti8g.png diff --git a/content/posts/joining-vms-to-active-directory-in-site-specific-ous-with-vra8/index.md b/content/posts/joining-vms-to-active-directory-in-site-specific-ous-with-vra8/index.md index 14cff51..c3e59fa 100644 --- a/content/posts/joining-vms-to-active-directory-in-site-specific-ous-with-vra8/index.md +++ b/content/posts/joining-vms-to-active-directory-in-site-specific-ous-with-vra8/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-07-21T00:00:00Z" thumbnail: 20210721-successful-ad_machine.png usePageBundles: true diff --git a/content/posts/k8s-on-vsphere-node-template-with-packer/index.md b/content/posts/k8s-on-vsphere-node-template-with-packer/index.md index 021cc6e..c0070ca 100644 --- a/content/posts/k8s-on-vsphere-node-template-with-packer/index.md +++ b/content/posts/k8s-on-vsphere-node-template-with-packer/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "thumbnail.jpg" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: K8s on vSphere +categories: VMware tags: - vmware - linux diff --git a/content/posts/ldaps-authentication-tanzu-community-edition/index.md b/content/posts/ldaps-authentication-tanzu-community-edition/index.md index 2845292..a5a360c 100644 --- a/content/posts/ldaps-authentication-tanzu-community-edition/index.md +++ b/content/posts/ldaps-authentication-tanzu-community-edition/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "ldaps_test.png" # Sets thumbnail image appearing inside card on homepage. shareImage: "ldaps_test.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: K8s on vSphere +categories: VMware tags: - vmware - kubernetes diff --git a/content/posts/logging-in-tce-cluster-from-new-device/index.md b/content/posts/logging-in-tce-cluster-from-new-device/index.md index c123a86..ebe2d73 100644 --- a/content/posts/logging-in-tce-cluster-from-new-device/index.md +++ b/content/posts/logging-in-tce-cluster-from-new-device/index.md @@ -14,7 +14,7 @@ featureImage: "tanzu.png" # Sets featured image on blog post. thumbnail: "tanzu.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips +categories: VMware tags: - vmware - kubernetes diff --git a/content/posts/logging-in-to-multiple-vcenter-servers-at-once-with-powercli/index.md b/content/posts/logging-in-to-multiple-vcenter-servers-at-once-with-powercli/index.md index c6a246f..26b4c29 100644 --- a/content/posts/logging-in-to-multiple-vcenter-servers-at-once-with-powercli/index.md +++ b/content/posts/logging-in-to-multiple-vcenter-servers-at-once-with-powercli/index.md @@ -1,5 +1,5 @@ --- -series: Code +categories: Code date: "2020-09-16T08:34:30Z" thumbnail: LJOcy2oqc.png usePageBundles: true diff --git a/content/posts/nessus-essentials-on-tanzu-community-edition/index.md b/content/posts/nessus-essentials-on-tanzu-community-edition/index.md index ba0cf71..03a8079 100644 --- a/content/posts/nessus-essentials-on-tanzu-community-edition/index.md +++ b/content/posts/nessus-essentials-on-tanzu-community-edition/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "nessus_login.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8 +categories: Self-Hosting tags: - vmware - kubernetes diff --git a/content/posts/notes-on-vra-ha-with-nsx-alb/index.md b/content/posts/notes-on-vra-ha-with-nsx-alb/index.md index e65a418..c68a4e8 100644 --- a/content/posts/notes-on-vra-ha-with-nsx-alb/index.md +++ b/content/posts/notes-on-vra-ha-with-nsx-alb/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-08-25T00:00:00Z" usePageBundles: true tags: @@ -13,7 +13,7 @@ title: Notes on vRA HA with NSX-ALB This is going to be a pretty quick recap of the steps I recently took to convert a single-node instance of vRealize Automation 8.4.2 into a 3-node High-Availability vRA cluster behind a standalone NSX Advanced Load Balancer (without NSX being deployed in the environment). No screenshots or specific details since I ran through this in the lab at work and didn't capture anything along the way, and my poor NUC homelab struggles enough to run a single instance of memory-hogging vRA. ### Getting started with NSX-ALB -I found a lot of information on how to use NSX-ALB as a component of a broader NSX-equipped environment, but not a lot of detail on how to use the ALB *without* NSX - until I found [Rudi Martinsen's blog on the subject](https://rudimartinsen.com/2021/06/25/load-balancing-with-nsx-alb/). That turned out to be a great reference for the ALB configuration so be sure to check it out if you need more details than what I provide in this section. +I found a lot of information on how to use NSX-ALB as a component of a broader NSX-equipped environment, but not a lot of detail on how to use the ALB *without* NSX - until I found [Rudi Martinsen's blog on the subject](https://rudimartinsen.com/2021/06/25/load-balancing-with-nsx-alb/). That turned out to be a great reference for the ALB configuration so be sure to check it out if you need more details than what I provide in this section. #### Download NSX-ALB is/was formerly known as the Avi Vantage Controller, and downloads are available [here](https://portal.avipulse.vmware.com/software/vantage). You'll need to log in with your VMware Customer Connect account to access the download, and then grab the latest VMware Controller OVA. Be sure to make a note of the default password listed on the right-hand side since you'll need that to log in post-deployment. @@ -45,7 +45,7 @@ Then go back to **Infastructure > Clouds**, edit the Cloud, and select the IPAM Navigate to **Infrastructure > Cloud Resources > Service Engine Group** and edit the *Default-Group*. I left everything on the *Basic Settings* tab at the defaults. On the *Advanced* tab, I specified which vSphere cluster the Service Engines should be deployed to. And I left everything else with the default settings. #### SSL Certificate -Hop over to **Templates > Security > SSL/TLS Certificates** and click **Create > Application Certificate**. Give the new cert a name and change the **Type** to `CSR` to generate a new signing request. Enter the **Common Name** you're going to want to use for the load balancer VIP (something like `vra`, perhaps?) and all the usual cert fields. Use the **Subject Alternate Name (SAN)** section at the bottom to add all the other components, like the individual vRA cluster members by both hostname and FQDN. I went ahead and included those IPs as well for good measure. +Hop over to **Templates > Security > SSL/TLS Certificates** and click **Create > Application Certificate**. Give the new cert a name and change the **Type** to `CSR` to generate a new signing request. Enter the **Common Name** you're going to want to use for the load balancer VIP (something like `vra`, perhaps?) and all the usual cert fields. Use the **Subject Alternate Name (SAN)** section at the bottom to add all the other components, like the individual vRA cluster members by both hostname and FQDN. I went ahead and included those IPs as well for good measure. | Name | |----------------------| @@ -60,14 +60,14 @@ Hop over to **Templates > Security > SSL/TLS Certificates** and click **Create > | `vra03` | | `192.168.1.43` | -Click **Save**. +Click **Save**. Click **Create** again, but this time select **Root/Intermediate CA Certificate** and upload/paste your CA's cert so it can be trusted. Save your work. Back at the cert list, find your new application cert and click the pencil icon to edit it. Copy the **Certificate Signing Request** field and go get it signed by your CA. Be sure to grab the certificate chain (base64-encoded) as well if you can. Come back and paste in / upload your shiny new CA-signed certificate file. #### Virtual Service -Now it's finally time to create the Virtual Service that will function as the load balancer front-end. Pop over to **Applications > Virtual Services** and click **Create Virtual Service > Basic Setup**. Give it a name and set the **Application Type** to `HTTPS`, which will automatically set the port and bind a default self-signed certificate. +Now it's finally time to create the Virtual Service that will function as the load balancer front-end. Pop over to **Applications > Virtual Services** and click **Create Virtual Service > Basic Setup**. Give it a name and set the **Application Type** to `HTTPS`, which will automatically set the port and bind a default self-signed certificate. Click on the **Certificate** field and select the new cert you created above. Be sure to remove the default cert. @@ -81,12 +81,12 @@ Now that the Virtual Service is created, make a note of the IP address assigned Log into LifeCycle Manager in a new browser tab/window. Make sure that you've mapped an *Install* product binary for your current version of vRA; the upgrade binary that you probably used to do your last update won't cut it. It's probably also a good idea to go make a snapshot of your vRA and IDM instances just in case. #### Adding new certificate -In LCM, go to **Locker > Certificates** and select the option to **Import**. Switch back to the NSX-ALB tab and go to **Templates > Security > SSL/TLS Certificates**. Click the little down-arrow-in-a-circle "Export" icon next to the application certificate you created earlier. Copy the key section and paste that into LCM. Then open the file containing the certificate chain you got from your CA, copy its contents, and paste it into LCM as well. Do *not* try to upload a certificate file directly to LCM; that will fail unless the file includes both the cert and the private key and that's silly. +In LCM, go to **Locker > Certificates** and select the option to **Import**. Switch back to the NSX-ALB tab and go to **Templates > Security > SSL/TLS Certificates**. Click the little down-arrow-in-a-circle "Export" icon next to the application certificate you created earlier. Copy the key section and paste that into LCM. Then open the file containing the certificate chain you got from your CA, copy its contents, and paste it into LCM as well. Do *not* try to upload a certificate file directly to LCM; that will fail unless the file includes both the cert and the private key and that's silly. Once the cert is successfully imported, go to the **Lifecycle Operations** component of LCM and navigate to the environment containing your vRA instance. Select the vRA product, hit the three-dot menu, and use the **Replace Certificate** option to replace the old and busted cert with the new HA-ready one. It will take a little bit for this to get applied. Don't move on until vRA services are back up. #### Scale out vRA -Still on the vRA product page, click on the **+ Add Components** button. +Still on the vRA product page, click on the **+ Add Components** button. On the **Infrastructure** page, tell LCM where to put the new VRA VMs. diff --git a/content/posts/powercli-list-linux-vms-and-datacenter-locations/index.md b/content/posts/powercli-list-linux-vms-and-datacenter-locations/index.md index 29d5d4e..1d7b22e 100644 --- a/content/posts/powercli-list-linux-vms-and-datacenter-locations/index.md +++ b/content/posts/powercli-list-linux-vms-and-datacenter-locations/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "PowerCLI.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Code +categories: Code tags: - vmware - powercli diff --git a/content/posts/powershell-download-web-folder-contents/index.md b/content/posts/powershell-download-web-folder-contents/index.md index a937ac8..db1961f 100644 --- a/content/posts/powershell-download-web-folder-contents/index.md +++ b/content/posts/powershell-download-web-folder-contents/index.md @@ -14,7 +14,7 @@ usePageBundles: true # thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Code +categories: Code tags: - powershell - windows diff --git a/content/posts/psa-halt-replication-before-snapshotting-linked-vcenters/index.md b/content/posts/psa-halt-replication-before-snapshotting-linked-vcenters/index.md index b7cde3f..c29a640 100644 --- a/content/posts/psa-halt-replication-before-snapshotting-linked-vcenters/index.md +++ b/content/posts/psa-halt-replication-before-snapshotting-linked-vcenters/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: VMware date: "2021-01-30T08:34:30Z" thumbnail: XTaU9VDy8.png usePageBundles: true diff --git a/content/posts/psa-microsoft-kb5022842-breaks-ws2022-secure-boot/index.md b/content/posts/psa-microsoft-kb5022842-breaks-ws2022-secure-boot/index.md index c117bb3..39cb801 100644 --- a/content/posts/psa-microsoft-kb5022842-breaks-ws2022-secure-boot/index.md +++ b/content/posts/psa-microsoft-kb5022842-breaks-ws2022-secure-boot/index.md @@ -14,7 +14,7 @@ usePageBundles: true # thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8, K8s on vSphere +categories: VMware # Projects, Code, vRA8, K8s on vSphere tags: - vmware - powershell diff --git a/content/posts/publish-services-cloudflare-tunnel/access-challenge.png b/content/posts/publish-services-cloudflare-tunnel/access-challenge.png new file mode 100644 index 0000000..a0b58f6 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/access-challenge.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/connector-online.png b/content/posts/publish-services-cloudflare-tunnel/connector-online.png new file mode 100644 index 0000000..e8141da Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/connector-online.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/create-policy.png b/content/posts/publish-services-cloudflare-tunnel/create-policy.png new file mode 100644 index 0000000..31f6300 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/create-policy.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/define-application.png b/content/posts/publish-services-cloudflare-tunnel/define-application.png new file mode 100644 index 0000000..a648483 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/define-application.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/index.md b/content/posts/publish-services-cloudflare-tunnel/index.md new file mode 100644 index 0000000..ec9c8c7 --- /dev/null +++ b/content/posts/publish-services-cloudflare-tunnel/index.md @@ -0,0 +1,182 @@ +--- +title: "Publish Services with Cloudflare Tunnel" +date: 2024-01-15 +# lastmod: 2024-01-13 +description: "Exploring Cloudflare Tunnel as an alternative to Tailscale Funnel for secure public access to internal resources." +featured: false +toc: true +comments: true +categories: Self-Hosting +tags: + - cloud + - containers + - docker + - networking + - selfhosting +--- +I've written a bit lately about how handy [Tailscale Serve and Funnel](/tailscale-ssh-serve-funnel/) can be, and I continue to get a lot of great use out of those features. But not *every* networking nail is best handled with a Tailscale-shaped hammer. Funnel has two limitations that might make it less than ideal for certain situations. + +First, sites served with Funnel can only have a hostname in the form of `server.tailnet-name.ts.net`. You can't use a custom domain for this, but you might not always want to advertise that a service is shared via Tailscale. Second, Funnel connections have an undisclosed bandwidth limit, which could cause problems if you're hoping to serve media through the Funnel. + +For instance, I've started using [Immich](https://immich.app/) as a self-hosted alternative to Google Photos. Using Tailscale Serve to make my Immich server available on my Tailnet works beautifully, and I initially set up a Funnel connection to use for when I wanted to share certain photos, videos, and albums externally. I quickly realized that it took *f o r e v e r* to load the page when those links were shared publicly. I probably won't share a lot of those public links but I'd like them to be a bit more responsive when I do. + +I went looking for another solution, and I found one in a suite of products I already use. + +### Overview +I've been using [Cloudflare's generious free plan](https://www.cloudflare.com/plans/free/) for DNS, content caching, page/domain redirects, email forwarding, and DDoS mitigation[^more] across my dozen or so domains. In addition to these "basic" services and features, Cloudflare also offers a selection of [Zero Trust Network Access](https://www.cloudflare.com/products/zero-trust/zero-trust-network-access/) products, and one of those is [Cloudflare Tunnel](https://www.cloudflare.com/products/tunnel/) - also available with a generous free plan. + +[^more]: And a ton of other things I'm forgetting right now. + +In some ways, Cloudflare Tunnel is quite similar to Tailscale Funnel. Both provide a secure way to publish a resource on the internet without requiring a public IP address, port forwarding, or firewall configuration. Both use a lightweight agent on your server to establish an encrypted outbound tunnel, and inbound traffic gets routed into that tunnel through the provider's network. And both solutions automatically provision trusted SSL certificates to keep traffic safe and browsers happy. + +Tailscale Funnel is very easy to set up, and it doesn't require any additional infrastructure, not even a domain name. There aren't a lot of controls available with Funnel - it's basically on or off, and bound to one of three port numbers. You don't get to pick the domain name where it's served, just the hostname of the Tailscale node - and if you want to share multiple resources on the same host you'll [need to get creative](/tailscale-serve-docker-compose-sidecar/). I think this approach is really ideal for quick development and testing scenarios. + +For longer-term, more production-like use, Cloudflare Tunnels is a pretty great fit. It ties in well with existing Cloudflare services, doesn't enforce a reduced bandwidth limit, and provides a bit more flexibility for how your resource will be presented to the web. It can also integrate tightly with the rest of Cloudflare's Zero Trust offerings to easily provide access controls to further protect your resource. It does, however, require a custom domain managed with Cloudflare DNS in order to work[^dns]. + +[^dns]: Cloudflare Tunnel lets you choose what hostname and domain name should be used for fronting your tunnel, and it even takes care of configuring the required DNS record automagically. + +For my specific Immich use case, I decided to share my instance via Tailscale Serve for internal access and Cloudflare Tunnel for public shares, and I used a similar sidecar approach to make it work without too much fuss. For the purposes of this blog post, though, I'm going to run through a less complicated example[^complexity]. + +[^complexity]: My Immich stack is using ~10 containers and I don't really feel like documenting that all here - not yet, at least. + +### Speedtest Demo +I'm going to deploy a quick [SpeedTest by OpenSpeedTest](https://github.com/openspeedtest/Speed-Test) container, and proxy it with both Tailscale Funnel and Cloudflare Tunnel so that I can compare the bandwidth of the two tunnel solutions directly. + +I'll start with a *very* basic Docker Compose definition for just the Speedtest container: + +```yaml +# torchlight! {"lineNumbers":true} +# docker-compose.yml +services: + speedtest: + image: openspeedtest/latest + container_name: speedtest + restart: unless-stopped +``` + +#### Tailscale Funnel +And, as in [my last post](/tailscale-serve-docker-compose-sidecar/) I'll add in my Tailscale sidecar to enable funnel: + +```yaml +# torchlight! {"lineNumbers":true} +# docker-compose.yml +services: + speedtest: + image: openspeedtest/latest + container_name: speedtest + restart: unless-stopped + network_mode: service:tailscale # [tl! ++:start focus:start] + tailscale: + image: ghcr.io/jbowdre/tailscale-docker:latest + container_name: speedtest-tailscaled + restart: unless-stopped + environment: + TS_AUTHKEY: ${TS_AUTHKEY:?err} + TS_HOSTNAME: ${TS_HOSTNAME:-tailscale-sidecar} + TS_STATE_DIR: "/var/lib/tailscale/" + TS_EXTRA_ARGS: ${TS_EXTRA_ARGS:-} + TS_SERVE_PORT: ${TS_SERVE_PORT:-} + TS_FUNNEL: ${TS_FUNNEL:-} # [tl! ++:end focus:end] +``` + +{{% notice note "Network Mode" %}} +I set `network_mode: service:tailscale` on the `speedtest` container so that it will share its network interface with the `tailscale` container. This allows Tailscale Serve/Funnel to proxy `speedtest` at `http://localhost:3000`, which is nice since Tailscale doesn't currently/officially support proxying remote hosts. +{{% /notice %}} + +I'll set up a new auth key in the [Tailscale Admin Portal](https://login.tailscale.com/admin/settings/keys), and insert that (along with hostname, port, and funnel configs) into my `.env` file: + +```shell +# torchlight! {"lineNumbers":true} +# .env +TS_AUTHKEY=tskey-auth-somestring-somelongerstring +TS_HOSTNAME=speedtest +TS_EXTRA_ARGS=--ssh +TS_SERVE_PORT=3000 # the port the speedtest runs on by default +TS_FUNNEL=true +``` + +A quick `docker compose up -d` and my new speedtest is alive! + +First I'll hit it at `http://speedtest.tailnet-name.ts.net:3000` to access it purely inside of my Tailnet: +![Speedtest from within the tailnet](speedtest-tailnet.png) + +Not bad! Now let's see what happens when I disable Tailscale on my laptop and hit the public Funnel endpoint at `https://speedtest.tailnet-name.ts.net`: +![Speedtest from funnel](speedtest-funnel.png) + +Oof. Routing traffic through the Funnel dropped the download by ~25% and the upload by **~90%**, not to mention the significant ping increase. + +#### Cloudflare Tunnel +Alright, let's throw a Cloudflare Tunnel on there and see what happens. + +To start that process, I'll log into my [Cloudflare dashboard](https://dash.cloudflare.com) and then use the side navigation to make my way to the **Zero Trust** (AKA "Cloudflare One") area. From there, I'll drill down through **Access -> Tunnels** and click on **+ Create a tunnel**. I'll give it an appropriate name like `speedtest` and then click **Save tunnel**. + +Now Cloudflare helpfully provides installation instructions for a variety of different platforms. I'm doing that Docker thing so I'll click the appropriate button and review that command snippet: +![Tunnel installation instructions](install-connector.png) + +I can easily adapt that and add it to my Docker Compose setup[^network-mode]: +```yaml +# torchlight! {"lineNumbers":true} +# docker-compose.yml +services: + speedtest: + image: openspeedtest/latest + container_name: speedtest + restart: unless-stopped + network_mode: service:tailscale + tailscale: # [tl! collapse:start] + image: ghcr.io/jbowdre/tailscale-docker:latest + container_name: speedtest-tailscaled + restart: unless-stopped + environment: + TS_AUTHKEY: ${TS_AUTHKEY:?err} + TS_HOSTNAME: ${TS_HOSTNAME:-tailscale} + TS_STATE_DIR: "/var/lib/tailscale/" + TS_EXTRA_ARGS: ${TS_EXTRA_ARGS:-} + TS_SERVE_PORT: ${TS_SERVE_PORT:-} + TS_FUNNEL: ${TS_FUNNEL:-} # [tl! collapse:end] + cloudflared: # [tl! ++:start focus:start] + image: cloudflare/cloudflared + container_name: speedtest-cloudflared + restart: unless-stopped + command: + - tunnel + - --no-autoupdate + - run + - --token + - ${CLOUDFLARED_TOKEN} + network_mode: service:tailscale # [tl! ++:end focus:end] +``` + +[^network-mode]: Setting the `network_mode` isn't strictly necessary for the `cloudflared` container since Cloudflare Tunnel *does* support proxying remote hosts, but I'll just stick with it here for consistency. + +After dropping the value for `CLOUDFLARED_TOKEN` into my `.env` file, I can do another `docker compose up -d` to bring this online - and that status will be reflected back on the config page as well: +![Connector is alive!](connector-online.png) + +I'll click **Next** and proceed with the rest of the configuration, which consists of picking a public hostname for the frontend and defining the private service for the backend: +![Tunnel configuration](tunnel-configuration.png) + +I can click **Save tunnel** and... that's it. My tunnel is live, and I can now reach my speedtest at `https://speedtest.runtimeterror.dev`. Let's see how it does: +![Cloudflare Tunnel speedtest](speedtest-cloudflared.png) + +So that's *much* faster than Tailscale Funnel, and even faster than a direct transfer within the Tailnet. Cloudflare Tunnel should work quite nicely for sharing photos publicly from my Immich instance. + +#### Bonus: Access Control +But what if I don't want *just anyone* to be able to use my new speedtest (or access my Immich instance)? Defining an application in Cloudflare One will let me set some limits. + +So I'll go to **Access -> Applications** and select that I'm adding a **Self-hosted** application. I can then do the basic configuration, basically just telling Cloudflare that I'd like to protect the `https://speedtest.runtimeterror.dev` app: +![Defining the application](define-application.png) + +I can leave the rest of that page with the default selections so I'll scroll down and click **Next**. + +Now I need to create a policy to apply to this application. I'm going to be simple and just say that anyone with an `@runtimeterror.dev` email address should be able to use my speedtest: +![Creating a policy](create-policy.png) + +Without any external identity providers connected, Cloudflare will default to requiring authentication via a one-time PIN sent to an input email address. That's pretty easy, and it pairs well with allowing access based on email address attributes. There are a bunch of other options I could configure if I wanted... but my needs are simple so I'll just click through and save this new application config. + +Now, if I try to visit my speedtest with a new session I'll get automatically routed to the Cloudflare Access challenge which will prompt for my email address. +![Access challenge](access-challenge.png) + +If my email is on the approved list (that is, if it ends with `@runtimeterror.dev`), I'll get emailed a code which I can then use to log in and access the speedtest. If not, I won't get in. And since this thing is served through a Cloudflare Tunnel (rather than a public IP address merely advertised via DNS) there isn't any way to bypass Cloudflare's authentication challenge. + +### Conclusion +This has been a quick demo of how easy it is to configure a Cloudflare Tunnel to securely publish resources on the web. I really like being able to share a service publicly without having to manage DNS, port-forwarding, or firewall configurations, and the ability to offload authentication and authorization to Cloudflare is a big plus. I still don't think Tailscale can be beat for sharing stuff internally, but I think Cloudflare Tunnels make more sense for long-term public sharing. And it's awesome that I can run both solutions side-by-side to really get the best of both when I need it. \ No newline at end of file diff --git a/content/posts/publish-services-cloudflare-tunnel/install-connector.png b/content/posts/publish-services-cloudflare-tunnel/install-connector.png new file mode 100644 index 0000000..9cc27f8 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/install-connector.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/speedtest-cloudflared.png b/content/posts/publish-services-cloudflare-tunnel/speedtest-cloudflared.png new file mode 100644 index 0000000..0e96b37 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/speedtest-cloudflared.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/speedtest-funnel.png b/content/posts/publish-services-cloudflare-tunnel/speedtest-funnel.png new file mode 100644 index 0000000..302d421 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/speedtest-funnel.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/speedtest-tailnet.png b/content/posts/publish-services-cloudflare-tunnel/speedtest-tailnet.png new file mode 100644 index 0000000..f787013 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/speedtest-tailnet.png differ diff --git a/content/posts/publish-services-cloudflare-tunnel/tunnel-configuration.png b/content/posts/publish-services-cloudflare-tunnel/tunnel-configuration.png new file mode 100644 index 0000000..c91aba4 Binary files /dev/null and b/content/posts/publish-services-cloudflare-tunnel/tunnel-configuration.png differ diff --git a/content/posts/recreating-hashnode-series-categories-in-jekyll-on-github-pages/index.md b/content/posts/recreating-hashnode-series-categories-in-jekyll-on-github-pages/index.md index 7c9b792..d393e19 100644 --- a/content/posts/recreating-hashnode-series-categories-in-jekyll-on-github-pages/index.md +++ b/content/posts/recreating-hashnode-series-categories-in-jekyll-on-github-pages/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: Backstage date: "2021-07-24T16:46:00Z" thumbnail: 20210724-series-navigation.png usePageBundles: true @@ -9,12 +9,12 @@ tags: title: Recreating Hashnode Series (Categories) in Jekyll on GitHub Pages --- -I recently [migrated this site](/virtually-potato-migrated-to-github-pages) from Hashnode to GitHub Pages, and I'm really getting into the flexibility and control that managing the content through Jekyll provides. So, naturally, after finalizing the move I got to work recreating Hashnode's "Series" feature, which lets you group posts together and highlight them as a collection. One of the things I liked about the Series setup was that I could control the order of the collected posts: my posts about [building out the vRA environment in my homelab](/series/vra8) are probably best consumed in chronological order (oldest to newest) since the newer posts build upon the groundwork laid by the older ones, while posts about my [other one-off projects](/series/projects) could really be enjoyed in any order. +I recently [migrated this site](/virtually-potato-migrated-to-github-pages) from Hashnode to GitHub Pages, and I'm really getting into the flexibility and control that managing the content through Jekyll provides. So, naturally, after finalizing the move I got to work recreating Hashnode's "Series" feature, which lets you group posts together and highlight them as a collection. One of the things I liked about the Series setup was that I could control the order of the collected posts: my posts about [building out the vRA environment in my homelab](/categories/vmware) are probably best consumed in chronological order (oldest to newest) since the newer posts build upon the groundwork laid by the older ones, while posts about my [other one-off projects](/categories/self-hosting) could really be enjoyed in any order. I quickly realized that if I were hosting this pretty much anywhere *other* than GitHub Pages I could simply leverage the [`jekyll-archives`](https://github.com/jekyll/jekyll-archives) plugin to manage this for me - but, alas, that's not one of the [plugins supported by the platform](https://pages.github.com/versions/). I needed to come up with my own solution, and being still quite new to Jekyll (and this whole website design thing in general) it took me a bit of fumbling to get it right. ### Reviewing the theme-provided option -The Jekyll theme I'm using ([Minimal Mistakes](https://github.com/mmistakes/minimal-mistakes)) comes with [built-in support](https://mmistakes.github.io/mm-github-pages-starter/categories/) for a [category archive page](/series), which (like the [tags page](/tags)) displays all the categorized posts on a single page. Links at the top will let you jump to an appropriate anchor to start viewing the selected category, but it's not really an elegant way to display a single category. +The Jekyll theme I'm using ([Minimal Mistakes](https://github.com/mmistakes/minimal-mistakes)) comes with [built-in support](https://mmistakes.github.io/mm-github-pages-starter/categories/) for a [category archive page](/categories), which (like the [tags page](/tags)) displays all the categorized posts on a single page. Links at the top will let you jump to an appropriate anchor to start viewing the selected category, but it's not really an elegant way to display a single category. ![Posts by category](20210724-posts-by-category.png) It's a start, though, so I took a few minutes to check out how it's being generated. The category archive page lives at [`_pages/category-archive.md`](https://raw.githubusercontent.com/mmistakes/mm-github-pages-starter/master/_pages/category-archive.md): @@ -144,7 +144,7 @@ Since I can't use a plugin to automatically generate pages for each series, I'll --- title: "Adventures in vRealize Automation 8" layout: series -permalink: "/series/vra8" +permalink: "/categories/vmware" tag: vRA8 sort_order: reverse author_profile: true @@ -155,9 +155,9 @@ header: *Follow along as I create a flexible VMware vRealize Automation 8 environment for provisioning virtual machines - all from the comfort of my Intel NUC homelab.* ``` -You can see that this page is referencing the series layout I just created, and it's going to live at `http://localhost/series/vra8` - precisely where this series was on Hashnode. I've tagged it with the category I want to feature on this page, and specified that the posts will be sorted in reverse order so that anyone reading through the series will start at the beginning (I hear it's a very good place to start). I also added a teaser image which will be displayed when I link to the series from elsewhere. And I included a quick little italicized blurb to tell readers what the series is about. +You can see that this page is referencing the series layout I just created, and it's going to live at `http://localhost/categories/vmware` - precisely where this series was on Hashnode. I've tagged it with the category I want to feature on this page, and specified that the posts will be sorted in reverse order so that anyone reading through the series will start at the beginning (I hear it's a very good place to start). I also added a teaser image which will be displayed when I link to the series from elsewhere. And I included a quick little italicized blurb to tell readers what the series is about. -Check it out [here](/series/vra8): +Check it out [here](/categories/vmware): ![vRA8 series](20210724-vra8-series.png) The other series pages will be basically the same, just without the reverse sort directive. Here's `_pages/series-tips.md`: @@ -202,7 +202,7 @@ author_profile: true ``` ### Fixing category links in posts -The bottom of each post has a section which lists the tags and categories to which it belongs. Right now, those are still pointing to the category archive page (`/series/#vra8`) instead of the series feature pages I created (`/series/vra8`). +The bottom of each post has a section which lists the tags and categories to which it belongs. Right now, those are still pointing to the category archive page (`/series/#vra8`) instead of the series feature pages I created (`/categories/vmware`). ![Old category link](20210724-old-category-link.png) That *works* but I'd rather it reference the fancy new pages I created. Tracking down where to make that change was a bit of a journey. @@ -245,7 +245,7 @@ Okay, it looks like [`_include/category-list.html`](https://github.com/mmistakes {% assign categories_sorted = page.categories | sort_natural %}

    - {{ site.data.ui-text[site.locale].categories_label | default: "series:" }} + {{ site.data.ui-text[site.locale].categories_label | default: "categories:" }} {% for category_word in categories_sorted %} {% unless forloop.last %}, {% endunless %} @@ -283,9 +283,9 @@ And, finally, I'll want to update the navigation links at the top of each page t # torchlight! {"lineNumbers": true} main: - title: "vRealize Automation 8" - url: /series/vra8 + url: /categories/vmware - title: "Projects" - url: /series/projects + url: /categories/self-hosting - title: "Code" url: /series/code - title: "Tips & Tricks" diff --git a/content/posts/removing-recreating-vcls-vms/index.md b/content/posts/removing-recreating-vcls-vms/index.md index 354189d..2b4a981 100644 --- a/content/posts/removing-recreating-vcls-vms/index.md +++ b/content/posts/removing-recreating-vcls-vms/index.md @@ -14,7 +14,7 @@ featureImage: "basic-architecture.png" # Sets featured image on blog post. thumbnail: "basic-architecture.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8 +categories: VMware # Projects, Code, vRA8 tags: - vmware - vsphere @@ -36,7 +36,7 @@ Fortunately there's a somewhat-hidden way to disable (and re-enable) vCLS on a p Disabling vCLS will break DRS, and could have other unintended side effects. Don't do this in prod if you can avoid it. {{% /notice %}} -[^off-and-on]: ![](off-and-on.gif) +[^off-and-on]: ![GIF from The IT Crowd: "Have you tried turning it off and back on again?"](off-and-on.gif) ### Find the cluster's domain ID It starts with determining the affected cluster's domain ID, which is very easy to do once you know where to look. Simply browse to the cluster object in the vSphere inventory, and look at the URL: diff --git a/content/posts/run-scripts-in-guest-os-with-vra-abx-actions/index.md b/content/posts/run-scripts-in-guest-os-with-vra-abx-actions/index.md index 86bba78..b48fef3 100644 --- a/content/posts/run-scripts-in-guest-os-with-vra-abx-actions/index.md +++ b/content/posts/run-scripts-in-guest-os-with-vra-abx-actions/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-09-03T00:00:00Z" thumbnail: 20210903_action_run_success.png usePageBundles: true @@ -11,7 +11,7 @@ tags: - vmware title: Run scripts in guest OS with vRA ABX Actions --- -Thus far in my [vRealize Automation project](/series/vra8), I've primarily been handing the payload over to vRealize Orchestrator to do the heavy lifting on the back end. This approach works really well for complex multi-part workflows (like when [generating unique hostnames](/vra8-custom-provisioning-part-two#the-vro-workflow)), but it may be overkill for more linear tasks (such as just running some simple commands inside of a deployed guest OS). In this post, I'll explore how I use [vRA Action Based eXtensibility (ABX)](https://blogs.vmware.com/management/2020/09/vra-abx-flow.html) to do just that. +Thus far in my [vRealize Automation project](/categories/vmware), I've primarily been handing the payload over to vRealize Orchestrator to do the heavy lifting on the back end. This approach works really well for complex multi-part workflows (like when [generating unique hostnames](/vra8-custom-provisioning-part-two#the-vro-workflow)), but it may be overkill for more linear tasks (such as just running some simple commands inside of a deployed guest OS). In this post, I'll explore how I use [vRA Action Based eXtensibility (ABX)](https://blogs.vmware.com/management/2020/09/vra-abx-flow.html) to do just that. ### The Goal My ABX action is going to use PowerCLI to perform a few steps inside a deployed guest OS (Windows-only for this demonstration): diff --git a/content/posts/safeguard-your-androids-battery-with-tasker-home-assistant/index.md b/content/posts/safeguard-your-androids-battery-with-tasker-home-assistant/index.md index 77ad62e..f319500 100644 --- a/content/posts/safeguard-your-androids-battery-with-tasker-home-assistant/index.md +++ b/content/posts/safeguard-your-androids-battery-with-tasker-home-assistant/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: Code date: "2020-11-14T08:34:30Z" thumbnail: aeIOr8w6k.png usePageBundles: true @@ -11,11 +11,11 @@ tags: title: Safeguard your Android's battery with Tasker + Home Assistant --- -A few months ago, I started using the [AccuBattery app](https://play.google.com/store/apps/details?id=com.digibites.accubattery) to keep a closer eye on how I'd been charging my phones. The app has a handy feature that notifies you once the battery level reaches a certain threshold so you can pull the phone off the charger and extend the lithium battery's service life, and it even offers an estimate for what that impact might be. For instance, right now the app indicates that charging my Pixel 5 from 51% to 100% would cause 0.92 wear cycles, while stopping the charge at 80% would impose just 0.17 cycles. +A few months ago, I started using the [AccuBattery app](https://play.google.com/store/apps/details?id=com.digibites.accubattery) to keep a closer eye on how I'd been charging my phones. The app has a handy feature that notifies you once the battery level reaches a certain threshold so you can pull the phone off the charger and extend the lithium battery's service life, and it even offers an estimate for what that impact might be. For instance, right now the app indicates that charging my Pixel 5 from 51% to 100% would cause 0.92 wear cycles, while stopping the charge at 80% would impose just 0.17 cycles. ![AccuBattery screenshot](aeIOr8w6k.png) -But that depends on me being near my phone and conscious so I can take action when the notification goes off. That's often a big assumption to make - and, frankly, I'm lazy. +But that depends on me being near my phone and conscious so I can take action when the notification goes off. That's often a big assumption to make - and, frankly, I'm lazy. I'm fortunately also fairly crafty, so I came up with a way to combine my favorite Android automation app with my chosen home automation platform to take my laziness out of the picture. @@ -25,7 +25,7 @@ I'm fortunately also fairly crafty, so I came up with a way to combine my favori - [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm) - [Home Assistant Plug-In for Tasker](https://play.google.com/store/apps/details?id=com.markadamson.taskerplugin.homeassistant) -I'm not going to go through how to install Home Assistant on the Pi or how to configure it beyond what's strictly necessary for this particular recipe. The official [getting started documentation](https://www.home-assistant.io/getting-started/) is a great place to start. +I'm not going to go through how to install Home Assistant on the Pi or how to configure it beyond what's strictly necessary for this particular recipe. The official [getting started documentation](https://www.home-assistant.io/getting-started/) is a great place to start. ### The Recipe 1. Plug the Wemo into a wall outlet, and plug a phone charger into the Wemo. Add the Belkin Wemo integration in Home Assistant, and configure the device and entity. I named mine `switchy`. Make a note of the Entity ID: `switch.switchy`. We'll need that later. @@ -37,7 +37,7 @@ For the Service field, you need to tell HA what you want it to do. We want it to ```json {"entity_id": "switch.switchy"} ``` -Tap Test Service to make sure it works - and verify that the switch does indeed turn off. +Tap Test Service to make sure it works - and verify that the switch does indeed turn off. ![Creating and testing the service](U3LfmEJ_7.png) 4. Hard part is over. Now we just need to set up a profile in Tasker to fire our new task. I named mine 'Charge Limiter'. I started with `State > Power > Battery Level` and set it to trigger between 81-100%., and also added `State > Power > Source: Any` so it will only be active while charging. I also only want this to trigger while my phone is charging at home, so I added `State > Net > Wifi Connected` and then specified my home SSID. Link this profile to the Task you created earlier, and never worry about overcharging your phone again. ![Tasker profile to kill power above 80%](h7tl6facr.png) diff --git a/content/posts/salt-state-netdata-tailscale/index.md b/content/posts/salt-state-netdata-tailscale/index.md index 4b12172..ba89b01 100644 --- a/content/posts/salt-state-netdata-tailscale/index.md +++ b/content/posts/salt-state-netdata-tailscale/index.md @@ -6,7 +6,7 @@ description: "A hasty Salt state to deploy netdata monitoring and publish it int featured: false toc: true comments: true -series: Code +categories: Code tags: - homelab - iac diff --git a/content/posts/script-to-convert-posts-to-hugo-page-bundles/index.md b/content/posts/script-to-convert-posts-to-hugo-page-bundles/index.md index 322c839..1673d13 100644 --- a/content/posts/script-to-convert-posts-to-hugo-page-bundles/index.md +++ b/content/posts/script-to-convert-posts-to-hugo-page-bundles/index.md @@ -15,7 +15,7 @@ thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homep # shareImage: "/images/path/share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. codeMaxLines: 30 -series: Code +categories: Backstage tags: - hugo - meta diff --git a/content/posts/script-to-update-image-embed-links-in-markdown-files/index.md b/content/posts/script-to-update-image-embed-links-in-markdown-files/index.md index 2c759cc..251fcd0 100644 --- a/content/posts/script-to-update-image-embed-links-in-markdown-files/index.md +++ b/content/posts/script-to-update-image-embed-links-in-markdown-files/index.md @@ -1,5 +1,5 @@ --- -series: Code +categories: Backstage date: "2021-07-19T16:03:30Z" usePageBundles: true tags: diff --git a/content/posts/secure-networking-made-simple-with-tailscale/index.md b/content/posts/secure-networking-made-simple-with-tailscale/index.md index 1d22617..5ea3455 100644 --- a/content/posts/secure-networking-made-simple-with-tailscale/index.md +++ b/content/posts/secure-networking-made-simple-with-tailscale/index.md @@ -14,7 +14,7 @@ featureImageAlt: 'Tailscale Logo' # Alternative text for featured image. thumbnail: "Tailscale-AppIcon.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects +categories: Self-Hosting tags: - vpn - wireguard diff --git a/content/posts/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications/index.md b/content/posts/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications/index.md index 7c62d7a..4b8dc2d 100644 --- a/content/posts/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications/index.md +++ b/content/posts/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications/index.md @@ -1,5 +1,5 @@ --- -series: Projects +categories: ChromeOS date: "2020-10-27T08:34:30Z" lastmod: "2021-05-20" thumbnail: XtmaR9Z0J.png diff --git a/content/posts/showdown-lenovo-chromebook-duet-vs-google-pixel-slate/index.md b/content/posts/showdown-lenovo-chromebook-duet-vs-google-pixel-slate/index.md index ebefe97..735ac28 100644 --- a/content/posts/showdown-lenovo-chromebook-duet-vs-google-pixel-slate/index.md +++ b/content/posts/showdown-lenovo-chromebook-duet-vs-google-pixel-slate/index.md @@ -4,6 +4,7 @@ thumbnail: P-x5qEg_9.jpeg usePageBundles: true tags: - chromeos +categories: ChromeOS title: 'Showdown: Lenovo Chromebook Duet vs. Google Pixel Slate' --- @@ -14,9 +15,9 @@ Okay, okay, this isn't actually going to be a comparison review between the two ### Background Up until last week, I'd been using the Slate as my primary personal computing device for the previous 20 months or so, mainly in laptop mode (as opposed to tablet mode). I do a lot of casual web browsing, and I spend a significant portion of my free time helping other users on Google's product support forums as a part of the [Google Product Experts program](https://productexperts.withgoogle.com/what-it-is). I also work a lot with the [Chrome OS Linux (Beta) environment](/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications), but I avoid Android apps as much as I can. And I also used the Slate for a bit of Stadia gaming when I wasn't near a Chromecast. -So the laptop experience is generally more important to me than the tablet one. I need to be able to work with a large number of browser tabs, but I don't typically need to do any heavy processing directly on the computer. +So the laptop experience is generally more important to me than the tablet one. I need to be able to work with a large number of browser tabs, but I don't typically need to do any heavy processing directly on the computer. -I was pretty happy with the Slate, but its expensive keyboard stopped working recently and replacements aren't really available anywhere. Remember, laptop mode is key for my use case so the Pixel Slate became instantly unusable to me. +I was pretty happy with the Slate, but its expensive keyboard stopped working recently and replacements aren't really available anywhere. Remember, laptop mode is key for my use case so the Pixel Slate became instantly unusable to me. ### Size When you put these machines side by side, the first difference that jumps out is the size disparity. The 12.3" Pixel Slate is positively massive next to the 10.1" Lenovo Duet. @@ -24,14 +25,14 @@ When you put these machines side by side, the first difference that jumps out is The Duet is physically smaller so the display itself is of course smaller. I had a brief moment of panic when I first logged in and the setup wizard completely filled the screen. Dialing Chrome OS's display scaling down to 80% strikes a good balance for me between fonts being legible while still displaying enough content to be worthwhile. It can get a bit tight when you've got windows docked side-by-side but I'm getting by okay. -Of course, the smaller size of the Duet also makes it work better as a tablet in my mind. It's comfortable enough to hold with one hand while you interact with the other, whereas the Slate always felt a little too big for that to me. +Of course, the smaller size of the Duet also makes it work better as a tablet in my mind. It's comfortable enough to hold with one hand while you interact with the other, whereas the Slate always felt a little too big for that to me. ![One-handing the Duet](qne9SybLi.jpeg) ### Keyboard A far more impactful size difference is the keyboards though. The Duet keyboard gets a bit cramped, particularly over toward the right side (you know, those pesky braces and semicolons that are *never* needed when coding): ![The Duet's keyboard is MUCH smaller](CBziPHD8A.jpeg) -Getting used to typing on this significantly smaller keyboard has been the biggest adjustment so far. The pad on my pinky finger is wider than the last few keys at the right edge of the keyboard so I've struggled with accurately hitting the correct `[` or `]`, and also with smacking Return (and inevitably sending a malformed chat message) when trying to insert an apostrophe. I feel like I'm slowly getting the hang of it, but like I said, it's been an adjustment. +Getting used to typing on this significantly smaller keyboard has been the biggest adjustment so far. The pad on my pinky finger is wider than the last few keys at the right edge of the keyboard so I've struggled with accurately hitting the correct `[` or `]`, and also with smacking Return (and inevitably sending a malformed chat message) when trying to insert an apostrophe. I feel like I'm slowly getting the hang of it, but like I said, it's been an adjustment. ### Cover ![Cover up!](yiCW6XZbF.jpeg) @@ -39,7 +40,7 @@ The Pixel Slate's keyboard + folio cover is a single (floppy) piece. The keyboar ![Duet's fabric cover](9_Ze3zyBk.jpeg) -The Duet's rear cover has a fabric finish kind of similar to the cases Google offers for their phones, and it provides a great texture for holding the tablet. It sticks to the back of the Duet through the magic of magnets, and the lower half of it folds out to create a really sturdy kickstand. And it's completely separate from the keyboard which is great for when you're using the Duet as a tablet (either handheld or propped up for watching a movie or gaming with Stadia). +The Duet's rear cover has a fabric finish kind of similar to the cases Google offers for their phones, and it provides a great texture for holding the tablet. It sticks to the back of the Duet through the magic of magnets, and the lower half of it folds out to create a really sturdy kickstand. And it's completely separate from the keyboard which is great for when you're using the Duet as a tablet (either handheld or propped up for watching a movie or gaming with Stadia). ![Duet kickstand](nWRu2TB8i.jpeg) @@ -48,9 +49,9 @@ And this little kickstand can go *low*, much lower than the Slate. This makes it ![The Duet handily wins this limbo competition](BAf7knBk5.jpeg) ### Performance -The Duet does struggle a bit here. It's basically got a [smartphone processor](https://www.notebookcheck.net/Mediatek-Helio-P60T-Processor-Benchmarks-and-Specs.470711.0.html) and half the RAM of the Slate. Switching between windows and tabs sometimes takes an extra moment or two to catch up (particularly if said tab has been silently suspended in the background). Similarly, working with Linux apps is just a bit slower than you'd like it to be. Still, I've spent a bit more than a week now with the Duet as my go-to computer and it's never really been slow enough to bother me. +The Duet does struggle a bit here. It's basically got a [smartphone processor](https://www.notebookcheck.net/Mediatek-Helio-P60T-Processor-Benchmarks-and-Specs.470711.0.html) and half the RAM of the Slate. Switching between windows and tabs sometimes takes an extra moment or two to catch up (particularly if said tab has been silently suspended in the background). Similarly, working with Linux apps is just a bit slower than you'd like it to be. Still, I've spent a bit more than a week now with the Duet as my go-to computer and it's never really been slow enough to bother me. -That arm64 processor does make finding compatible Linux packages a little more difficult than it's been on amd64 architectures but a [little bit of digging](/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications) will get past that limitation in most cases. +That arm64 processor does make finding compatible Linux packages a little more difficult than it's been on amd64 architectures but a [little bit of digging](/setting-up-linux-on-a-new-lenovo-chromebook-duet-bonus-arm64-complications) will get past that limitation in most cases. The upside of that smartphone processor is that the battery life is *insane*. After about seven hours of light usage today I'm sitting at 63% - with an estimated nine hours remaining. This thing keeps going and going, even while Stadia-ing for hours. Being able to play Far Cry 5 without being tethered to a wall is so nice. diff --git a/content/posts/snikket-private-xmpp-chat-on-oracle-cloud-free-tier/index.md b/content/posts/snikket-private-xmpp-chat-on-oracle-cloud-free-tier/index.md index 6051bca..7311d63 100644 --- a/content/posts/snikket-private-xmpp-chat-on-oracle-cloud-free-tier/index.md +++ b/content/posts/snikket-private-xmpp-chat-on-oracle-cloud-free-tier/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "snikket.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects +categories: Self-Hosting tags: - linux - cloud diff --git a/content/posts/spotlight-on-torchlight/index.md b/content/posts/spotlight-on-torchlight/index.md index 4dd2f0c..f42c4e1 100644 --- a/content/posts/spotlight-on-torchlight/index.md +++ b/content/posts/spotlight-on-torchlight/index.md @@ -6,7 +6,7 @@ description: "Syntax highlighting powered by the Torchlight.dev API makes it eas featured: false toc: true comments: true -series: Projects # Projects, Code +categories: Backstage tags: - javascript - hugo @@ -536,7 +536,7 @@ Serving HTTP on 0.0.0.0 port 1313 (http://0.0.0.0:1313/) ... # [tl! focus:1] #### Netlify Setting up Netlify to leverage the Torchlight API is kind of similar. I'll start with logging in to the [Netlify dashboard](https://app.netlify.com) and navigating to **Site Configuration > Environment Variables**. There, I'll click on **Add a variable > Add a ingle variable**. I'll give the new variable a key of `TORCHLIGHT_TOKEN` and set its value to the token I obtained earlier. -![](netlify-env-var.png) +![Screenshot showing the creation of the 'TORCHLIGHT_TOKEN' variable in Netlify](netlify-env-var.png) Once that's done, I edit the `netlify.toml` file at the root of my site repo to alter the build commands: ```toml diff --git a/content/posts/systemctl-edit-delay-service-startup/index.md b/content/posts/systemctl-edit-delay-service-startup/index.md index d4df138..a4b8b87 100644 --- a/content/posts/systemctl-edit-delay-service-startup/index.md +++ b/content/posts/systemctl-edit-delay-service-startup/index.md @@ -6,7 +6,7 @@ description: "Quick notes on using `systemctl edit` to override a systemd servic featured: false toc: false comments: true -series: Tips # Projects, Code +categories: Tips # Projects, Code tags: - crostini - linux diff --git a/content/posts/tailscale-golink-private-shortlinks-tailnet/index.md b/content/posts/tailscale-golink-private-shortlinks-tailnet/index.md index 32eae50..5c2fba1 100644 --- a/content/posts/tailscale-golink-private-shortlinks-tailnet/index.md +++ b/content/posts/tailscale-golink-private-shortlinks-tailnet/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "golinks.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Projects # Projects, Code, vRA8, K8s on vSphere +categories: Self-Hosting # Projects, Code, vRA8, K8s on vSphere tags: - docker - vpn diff --git a/content/posts/tailscale-on-vmware-photon/index.md b/content/posts/tailscale-on-vmware-photon/index.md index 86ff567..4ed4011 100644 --- a/content/posts/tailscale-on-vmware-photon/index.md +++ b/content/posts/tailscale-on-vmware-photon/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "Tailscale-AppIcon.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8, K8s on vSphere +categories: Tips # Projects, Code, vRA8, K8s on vSphere tags: - vmware - linux diff --git a/content/posts/tailscale-serve-docker-compose-sidecar/index.md b/content/posts/tailscale-serve-docker-compose-sidecar/index.md index e06e37b..498bd04 100644 --- a/content/posts/tailscale-serve-docker-compose-sidecar/index.md +++ b/content/posts/tailscale-serve-docker-compose-sidecar/index.md @@ -6,7 +6,7 @@ description: "Using Docker Compose to deploy containerized applications and make featured: false toc: true comments: true -series: Projects +categories: Self-Hosting tags: - containers - docker diff --git a/content/posts/tailscale-ssh-serve-funnel/index.md b/content/posts/tailscale-ssh-serve-funnel/index.md index ab73d8b..2bd7d0b 100644 --- a/content/posts/tailscale-ssh-serve-funnel/index.md +++ b/content/posts/tailscale-ssh-serve-funnel/index.md @@ -6,7 +6,7 @@ description: "Exploring some of my favorite Tailscale addon features: SSH, Serve featured: false toc: true comments: true -series: Tips # Projects, Code +categories: Tips # Projects, Code tags: - homelab - networking diff --git a/content/posts/tanzu-community-edition-k8s-homelab/index.md b/content/posts/tanzu-community-edition-k8s-homelab/index.md index 65fa9dc..ab740d3 100644 --- a/content/posts/tanzu-community-edition-k8s-homelab/index.md +++ b/content/posts/tanzu-community-edition-k8s-homelab/index.md @@ -14,7 +14,7 @@ usePageBundles: true thumbnail: "tanzu_community_edition.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: K8s on vSphere +categories: VMware tags: - vmware - linux @@ -983,7 +983,8 @@ I'll define the new subnet as `192.168.1.0/24`. Once I enable the option to *Che ![A new (but empty) subnet](new_subnet_pre_scan.png) It shows the scanner associated with the subnet, but no data yet. I'll need to wait a few minutes for the first scan to kick off (at the five-minute interval I defined in the configuration). -![](five_minutes.gif) + +![GIF which says 'Five Minutes Later!'](five_minutes.gif) ![Newly discovered IPs!](newly-discovered_IPs.png) Woah, it actually works! diff --git a/content/posts/upgrading-standalone-vsphere-host-with-esxcli/index.md b/content/posts/upgrading-standalone-vsphere-host-with-esxcli/index.md index 7d89bc1..e2bcc91 100644 --- a/content/posts/upgrading-standalone-vsphere-host-with-esxcli/index.md +++ b/content/posts/upgrading-standalone-vsphere-host-with-esxcli/index.md @@ -14,7 +14,7 @@ featureImage: "esxi8.png" # Sets featured image on blog post. # thumbnail: "thumbnail.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8 +categories: VMware # Projects, Code, vRA8 tags: - vmware - homelab diff --git a/content/posts/using-powershell-and-a-scheduled-task-to-apply-windows-updates/index.md b/content/posts/using-powershell-and-a-scheduled-task-to-apply-windows-updates/index.md index b2e5244..fe37d42 100644 --- a/content/posts/using-powershell-and-a-scheduled-task-to-apply-windows-updates/index.md +++ b/content/posts/using-powershell-and-a-scheduled-task-to-apply-windows-updates/index.md @@ -1,5 +1,5 @@ --- -series: Code +categories: Code date: "2021-04-29T08:34:30Z" usePageBundles: true tags: @@ -9,7 +9,7 @@ title: Using PowerShell and a Scheduled Task to apply Windows Updates toc: false --- -In the same vein as [my script to automagically resize a Linux LVM volume to use up free space on a disk](/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk), I wanted a way to automatically apply Windows updates for servers deployed by [my vRealize Automation environment](/series/vra8). I'm only really concerned with Windows Server 2019, which includes the [built-in Windows Update Provider PowerShell module](https://4sysops.com/archives/scan-download-and-install-windows-updates-with-powershell/). So this could be as simple as `Install-WUUpdates -Updates (Start-WUScan)` to scan for and install any available updates. +In the same vein as [my script to automagically resize a Linux LVM volume to use up free space on a disk](/automatic-unattended-expansion-of-linux-root-lvm-volume-to-fill-disk), I wanted a way to automatically apply Windows updates for servers deployed by [my vRealize Automation environment](/categories/vmware). I'm only really concerned with Windows Server 2019, which includes the [built-in Windows Update Provider PowerShell module](https://4sysops.com/archives/scan-download-and-install-windows-updates-with-powershell/). So this could be as simple as `Install-WUUpdates -Updates (Start-WUScan)` to scan for and install any available updates. Unfortunately, I found that this approach can take a long time to run and often exceeded the timeout limits imposed upon my ABX script, causing the PowerShell session to end and terminating the update process. I really needed a way to do this without requiring a persistent session. diff --git a/content/posts/using-vs-code-to-explore-giant-log-bundles/index.md b/content/posts/using-vs-code-to-explore-giant-log-bundles/index.md index 2c7d3c9..a0209de 100644 --- a/content/posts/using-vs-code-to-explore-giant-log-bundles/index.md +++ b/content/posts/using-vs-code-to-explore-giant-log-bundles/index.md @@ -1,5 +1,5 @@ --- -series: Tips +categories: Tips date: "2021-02-18T08:34:30Z" thumbnail: PPZu_UOGO.png usePageBundles: true diff --git a/content/posts/using-vsphere-diagnostic-tool-fling/index.md b/content/posts/using-vsphere-diagnostic-tool-fling/index.md index e981d2c..2051cbe 100644 --- a/content/posts/using-vsphere-diagnostic-tool-fling/index.md +++ b/content/posts/using-vsphere-diagnostic-tool-fling/index.md @@ -14,7 +14,7 @@ featureImage: "vdt.png" # Sets featured image on blog post. thumbnail: "pulse2.png" # Sets thumbnail image appearing inside card on homepage. # shareImage: "share.png" # Designate a separate image for social media sharing. codeLineNumbers: false # Override global value for showing of line numbers within code block. -series: Tips # Projects, Code, vRA8 +categories: VMware # Projects, Code, vRA8 tags: - vmware - vsphere diff --git a/content/posts/virtually-potato-migrated-to-github-pages/index.md b/content/posts/virtually-potato-migrated-to-github-pages/index.md index adedfa9..d22b476 100644 --- a/content/posts/virtually-potato-migrated-to-github-pages/index.md +++ b/content/posts/virtually-potato-migrated-to-github-pages/index.md @@ -2,6 +2,7 @@ date: "2021-07-20T22:20:00Z" thumbnail: 20210720-jekyll.png usePageBundles: true +categories: Backstage tags: - linux - meta @@ -71,4 +72,4 @@ And there it is! ### `git push` time Alright that's enough rambling for now. I'm very happy with this new setup, particularly with the automatically-generated Table of Contents to help folks navigate some of my longer posts. (I can't believe I was having to piece those together manually in this blog's previous iteration!) -I'll continue to make some additional tweaks in the coming weeks but for now I'll `git push` this post and get back to documenting my never-ending [vRA project](/series/vra8). \ No newline at end of file +I'll continue to make some additional tweaks in the coming weeks but for now I'll `git push` this post and get back to documenting my never-ending [vRA project](/categories/vmware). \ No newline at end of file diff --git a/content/posts/virtuallypotato-runtimeterror/index.md b/content/posts/virtuallypotato-runtimeterror/index.md index 27046d5..2babfd2 100644 --- a/content/posts/virtuallypotato-runtimeterror/index.md +++ b/content/posts/virtuallypotato-runtimeterror/index.md @@ -7,6 +7,7 @@ draft: false description: "This blog has migrated from virtuallypotato.com to runtimeterror.dev." toc: false comments: true +categories: Backstage tags: - meta --- @@ -19,7 +20,7 @@ ln -s virtuallypotato.com runtimeterror.dev If you've noticed that things look a bit different around here, you might *also* have noticed that my posts about VMware products had become less and less frequent over the past year or so. That wasn't intentional, but a side-effect of some shifting priorities with a new position at work. I'm no longer on the team responsible for our VMware environment and am now more focused on cloud-native technologies and open-source DevOps solutions. The new role keeps me pretty busy, and I'm using what free time I have to learn more about and experiment with the technologies I use at work. -That (unfortunately) means that I won't be posting much (if at all) about VMware-related things (including the [vRA8 series of posts](/series/vra8/))[^vra8] going forward. Instead, expect to see more posts about things like [containers](/tags/containers/), [infrastructure-as-code](/tags/iac/), [self-hosting](/tags/selfhosting/), and [miscellaneous tech projects](/series/projects/) that I play with. +That (unfortunately) means that I won't be posting much (if at all) about VMware-related things (including the [vRA8 series of posts](/categories/vmware/))[^vra8] going forward. Instead, expect to see more posts about things like [containers](/tags/containers/), [infrastructure-as-code](/tags/iac/), [self-hosting](/tags/selfhosting/), and [miscellaneous tech projects](/categories/self-hosting/) that I play with. I decided to migrate, rebrand, and re-theme my blog to reflect this change in focus. virtuallypotato used a [theme heavily inspired by VMware design language](https://github.com/chipzoller/hugo-clarity), and I don't think it's a great fit for the current (and future) content anymore. That theme is also very feature-rich which provides a lot of capability out of the box but makes it a bit tricky to modify (and maintain) my personal tweaks. The new runtimeterror[^pun] site uses a [more minimal theme](https://github.com/joeroe/risotto) which takes cues from terminals and markdown formatting. It's also simpler and thus easier for me to tweak. I've done a lot of that already and anticipating doing a bit more in the coming weeks, but I wanted to go ahead and make this thing "live" for now. diff --git a/content/posts/vmware-home-lab-on-intel-nuc-9/index.md b/content/posts/vmware-home-lab-on-intel-nuc-9/index.md index 410cc54..bc6f20a 100644 --- a/content/posts/vmware-home-lab-on-intel-nuc-9/index.md +++ b/content/posts/vmware-home-lab-on-intel-nuc-9/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-02-05T08:34:30Z" thumbnail: SIDah-Lag.png usePageBundles: true diff --git a/content/posts/vra8-automatic-deployment-naming-another-take/index.md b/content/posts/vra8-automatic-deployment-naming-another-take/index.md index 071f50e..48ce81e 100644 --- a/content/posts/vra8-automatic-deployment-naming-another-take/index.md +++ b/content/posts/vra8-automatic-deployment-naming-another-take/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-05-20T08:34:30Z" thumbnail: wl-WPQpEl.png usePageBundles: true diff --git a/content/posts/vra8-custom-provisioning-part-four/index.md b/content/posts/vra8-custom-provisioning-part-four/index.md index dc93d30..01711e7 100644 --- a/content/posts/vra8-custom-provisioning-part-four/index.md +++ b/content/posts/vra8-custom-provisioning-part-four/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-05-18T08:34:30Z" lastmod: "2021-05-20" thumbnail: hFPeakMxn.png diff --git a/content/posts/vra8-custom-provisioning-part-one/index.md b/content/posts/vra8-custom-provisioning-part-one/index.md index a8a1699..34c3f6d 100644 --- a/content/posts/vra8-custom-provisioning-part-one/index.md +++ b/content/posts/vra8-custom-provisioning-part-one/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-03-29T08:34:30Z" thumbnail: VZaK4btzl.png usePageBundles: true diff --git a/content/posts/vra8-custom-provisioning-part-three/index.md b/content/posts/vra8-custom-provisioning-part-three/index.md index f4b0de6..e9bfd8c 100644 --- a/content/posts/vra8-custom-provisioning-part-three/index.md +++ b/content/posts/vra8-custom-provisioning-part-three/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-04-19T08:34:30Z" thumbnail: K6vcxpDj8.png usePageBundles: true diff --git a/content/posts/vra8-custom-provisioning-part-two/index.md b/content/posts/vra8-custom-provisioning-part-two/index.md index 2dbaf4b..b7d0e69 100644 --- a/content/posts/vra8-custom-provisioning-part-two/index.md +++ b/content/posts/vra8-custom-provisioning-part-two/index.md @@ -1,5 +1,5 @@ --- -series: vRA8 +categories: VMware date: "2021-04-02T08:34:30Z" lastmod: "2022-03-23" thumbnail: HXrAMJrH.png @@ -331,9 +331,9 @@ I'll do that with another scriptable task element, named `Apply new names`, whic {{% notice note "Binding a workflow output" %}} To easily create a new workflow output and bind it to a task's output, click the task's **Add New** option like usual: -![](add_new.png) +![Screenshot showing the creation of a new output](add_new.png) Select **Output** at the top of the *New Variable* dialog and the complete the form with the other required details: -![](new_output_parameter.png) +![Screenshot showing the new output parameter with 'Name: resourceNames' and 'Type: string'](new_output_parameter.png) {{% /notice %}} diff --git a/content/search/_index.md b/content/search/_index.md new file mode 100644 index 0000000..d810fcb --- /dev/null +++ b/content/search/_index.md @@ -0,0 +1,3 @@ +--- +title: Search Results Page +--- \ No newline at end of file diff --git a/content/simplex.md b/content/simplex.md index 3bdf23f..70afed5 100644 --- a/content/simplex.md +++ b/content/simplex.md @@ -10,7 +10,7 @@ title = "SimpleX Chat" +++ *You can **[contact me on SimpleX Chat](https://l.runtimeterror.dev/simplex-chat-invite)** by clicking that link or scanning the QR code below.* -![](/images/simplex-invite.png) +![QR code](/images/simplex-invite.png) [SimpleX Chat](https://simplex.chat/) is a secure messaging solution with a strong emphasis on user privacy. It's (naturally) end-to-end encrypted, doesn't require (or collect) *any* information about you in order to sign up, doesn't use any persistent user identifiers (not even a randomly-generated one), is fully decentralized, and is *not* affiliated with any cryptocurrency project/scam. @@ -19,37 +19,37 @@ Incoming messages are routed through a pool of servers so that your conversation The app is also packed with other features like disappearing messages, encrypted file transfers, encrypted voice messages, encrypted audio and video calls, decentralized private groups, and a cool incognito mode which connects new conversations to a randomly-generated profile instead of your primary one. There's even a [CLI client](https://github.com/simplex-chat/simplex-chat/blob/stable/docs/CLI.md)! ## Servers -[![](https://status.vpota.to/api/badge/11/status)](https://status.vpota.to/status/simplex) +[![Status badge](https://status.runtimeterror.dev/api/badge/11/status)](https://status.runtimeterror.dev/status/simplex) You can easily host your own [simplexmq server](https://github.com/simplex-chat/simplexmq) for handling your inbound message queue, and I've done just that; in fact, I've deployed three! And, as one of my closest internet friends, *you're welcome to use them as well.* Just add these in the SimpleX app at **Settings > Network & servers > SMP servers > + Add server...**. Enable the option to use them for new connections, and they'll be added to the pool used for incoming messages in new conversations. If you want to use them immediately for existing conversations, go into each conversation's options menu and use the **Switch receiving address** option. You can also *disable* the option to use the default servers for new conversations if you only want messages to be routed through specific servers, but that does increase the likelikhood of concurrent conversations being routed the same way. More servers, more path options, less metadata in any one place. --- -![](/images/smp-vpota-to.png) +![QR code](/images/smp-vpota-to.png) `smp://kYx5LmVD9FMM8hJN4BQqL4WmeUNZn8ipXsX2UkBoiHE=@smp.vpota.to` | | | | --- | --- | -| [![](https://status.vpota.to/api/badge/6/uptime)](https://status.vpota.to/status/simplex) | [[details](https://l.runtimeterror.dev/smp_status)] | +| [![Status badge](https://status.runtimeterror.dev/api/badge/6/uptime)](https://status.runtimeterror.dev/status/simplex) | [[details](https://l.runtimeterror.dev/smp_status)] | --- -![](/images/smp1-vpota-to.png) +![QR code](/images/smp1-vpota-to.png) `smp://TbUrGydawdVKID0Lvix14UkaN-WarFgqXx4kaEG8Trw=@smp1.vpota.to` | | | | --- | --- | -| [![](https://status.vpota.to/api/badge/4/uptime)](https://status.vpota.to/status/simplex) | [[details](https://l.runtimeterror.dev/smp1_status)] | +| [![Status badge](https://status.runtimeterror.dev/api/badge/4/uptime)](https://status.runtimeterror.dev/status/simplex) | [[details](https://l.runtimeterror.dev/smp1_status)] | --- -![](/images/smp2-vpota-to.png) +![QR code](/images/smp2-vpota-to.png) `smp://tNfQisxTQ9MhKpFDTbx9RnjgWigtxF1a26jroy5-rR4=@smp2.vpota.to` | | | | --- | --- | -| [![](https://status.vpota.to/api/badge/5/uptime)](https://status.vpota.to/status/simplex) | [[details](https://l.runtimeterror.dev/smp2_status)] | +| [![Status badge](https://status.runtimeterror.dev/api/badge/5/uptime)](https://status.runtimeterror.dev/status/simplex) | [[details](https://l.runtimeterror.dev/smp2_status)] | diff --git a/content/uses.md b/content/uses.md new file mode 100644 index 0000000..3afe333 --- /dev/null +++ b/content/uses.md @@ -0,0 +1,19 @@ +--- +title: "Stuff I Use" +date: "2024-01-19T04:15:31Z" +# lastmod: {{ .Date | time.Format "2006-01-02" }} +description: "The hardware, software, and services which keep me going." +toc: true +draft: true +comments: true +timeless: true +--- +Here's the stuff I use and how I use it. + +### Hardware +- **[Framework Laptop Chromebook Edition](https://frame.work/products/laptop-chromebook-12-gen-intel)** (i5-1240P | 32GB RAM | 1TB NVMe). This is my primary personal computing device. Yep, it's an overpowered Chromebook, and I make full use of the [Linux Development Environment](https://www.chromium.org/chromium-os/developer-library/guides/containers/containers-and-vms/) to Do Things. I love it. +- + +### Software + +### Services diff --git a/layouts/_default/index.json b/layouts/_default/index.json deleted file mode 100644 index fdb9ebc..0000000 --- a/layouts/_default/index.json +++ /dev/null @@ -1,7 +0,0 @@ -{{- $.Scratch.Add "index" slice -}} -{{- range .Site.Pages -}} - {{- if ne .Type "search" -}} - {{- $.Scratch.Add "index" (dict "title" .Title "body" .Plain "link" .Permalink "section" .Section "tags" .Params.tags) -}} - {{- end -}} -{{- end -}} -{{- jsonify (uniq ($.Scratch.Get "index")) -}} \ No newline at end of file diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 6a7f770..373a6b8 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -10,9 +10,10 @@ {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} {{- end -}} -{{- printf "" | safeHTML }} + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} @@ -40,7 +41,11 @@ {{ range (.GetTerms "tags") }} {{ .LinkTitle }}{{ end }} {{ .Permalink }} - {{ .Summary | plainify }} + {{- $content := replaceRE "a href=\"(#.*?)\"" (printf "%s%s%s" "a href=\"" .Permalink "$1\"") .Content -}} + {{- $content = replaceRE "img src=\"(.*?)\"" (printf "%s%s%s" "img src=\"" .Permalink "$1\"") $content -}} + {{- $content = replaceRE "" "" $content -}} + {{- $content = replaceRE `-moz-tab-size:\d;-o-tab-size:\d;tab-size:\d;?` "" $content -}} + {{ $content | html }} {{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index a0af61c..c4e22aa 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,7 +1,24 @@ {{ define "main" }} {{- $ageDays := div (sub now.Unix .Date.Unix) 86400 -}}

    -

    {{ .Title | markdownify }}

    +
    +
    + + + {{- if .Params.date }} + {{- $postDate := .Date.Format "2006-01-02" }} + {{- $updateDate := .Lastmod.Format "2006-01-02" }} + + {{- if ne $postDate $updateDate }} + + {{ end }} + {{ end }} + {{- with .Params.tags }}{{- $tagCount := len . }} + + {{- end }} +
    title:{{ .Title | markdownify }}
    posted:{{ $postDate }}
    updated:{{ $updateDate }}
    tags:{{- if gt $tagCount 5 }}
    See all {{ $tagCount }} tags...{{- end }}["all" {{- range . }}{{- $tag := urlize . }}{{ if $tag }}, {{ end }}"{{ . }}"{{- end }}]{{- if gt $tagCount 5 }}
    {{- end }}
    +
    +
    {{- with .Param "lastmod" -}} {{- $ageDays = div (sub now.Unix .Unix) 86400 -}} @@ -16,6 +33,7 @@
    {{ .Content }}
    + {{- $showComments := true }} {{- if eq .Site.Params.comments false }} {{- $showComments = false }} @@ -23,6 +41,10 @@ {{- $showComments = false }} {{- end }} {{- if ne $showComments false }} +
    + {{- if eq .Site.Params.analytics true }} + Enjoyed this post?  + {{- end }} {{- partial "comments" . }} {{- end }}
    diff --git a/layouts/partials/about.html b/layouts/partials/about.html index 29869da..346de25 100644 --- a/layouts/partials/about.html +++ b/layouts/partials/about.html @@ -14,3 +14,4 @@ {{ end }} +{{ partial "search-form.html" . }} diff --git a/layouts/partials/archive.html b/layouts/partials/archive.html index 3cbf057..02d0ca1 100644 --- a/layouts/partials/archive.html +++ b/layouts/partials/archive.html @@ -6,32 +6,58 @@ {{ if .IsHome }}

    {{ site.Params.indexTitle | markdownify }}

    {{ else }} -

    {{ .Title | markdownify }}{{ if eq .Kind "term" }}  

    {{ end }} -{{ end }} +

    {{ .Title | markdownify }}{{ if eq .Kind "term" }}  

    + {{ with .Description }}{{ . }}
    {{ else }}
    {{ end }} +{{ end }}{{ end }} {{ .Content }} -{{- if ne .Title "Tags"}} -{{- range (.Paginate $pages).Pages }} -{{- $postDate := .Date.Format "2006-01-02" }} -{{- $updateDate := .Lastmod.Format "2006-01-02" }} -
    -
    -

    {{ .Title | markdownify }}

    - -
    - -
    - {{ .Summary }} -
    -
    -
    -{{ end }} -{{- template "_internal/pagination.html" . }} +{{- if eq .Kind "taxonomy" }} + {{- if eq .Title "Tags" }} +
    + {{- range $key, $value := .Site.Taxonomies }} + {{- $slicedTags := ($value.ByCount) }} + {{- range $slicedTags }} + {{- if eq $key "tags"}} +
    {{ .Name }}{{ .Count }}
    + {{- end }} + {{- end }} + {{- end }} +
    + {{- else }} + {{- range .Pages.ByDate.Reverse }} + {{- $postDate := .Date.Format "2006-01-02" }} + {{- $updateDate := .Lastmod.Format "2006-01-02" }} +
    +
    +

    {{ .Title | markdownify }}

    + +
    +
    + {{ .Description }} +
    +
    +
    + {{ end }} + {{- end }} {{- else }} -{{- range .Pages.ByTitle }} - [{{ .Title | markdownify }}] -{{- end }} + {{- range (.Paginate $pages).Pages }} + {{- $postDate := .Date.Format "2006-01-02" }} + {{- $updateDate := .Lastmod.Format "2006-01-02" }} +
    +
    +

    {{ .Title | markdownify }}

    + +
    +
    + {{ .Summary }} +
    +
    +
    + {{- end }} + {{- template "_internal/pagination.html" . }} {{- end }} \ No newline at end of file diff --git a/layouts/partials/aside.html b/layouts/partials/aside.html index 0326171..28a9d08 100644 --- a/layouts/partials/aside.html +++ b/layouts/partials/aside.html @@ -1,36 +1,16 @@ -{{- $postDate := .Date.Format "2006-01-02" }} -{{- $updateDate := .Lastmod.Format "2006-01-02" }} -{{ if or (.Params.description) (.Params.date) }} - {{ if .Params.description }}

    {{ .Params.description }}

    {{ end }} -

    - {{ if .Params.date }}{{- if ne $postDate $updateDate }}{{ end }}
    posted:{{ $postDate }}
    updated:{{ $updateDate }}
    {{ end }} -

    +{{ if .Params.description }}

    {{ .Params.description }}


    {{ end }} +{{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) }} +

    +

    On this page

    + {{ .TableOfContents }}
    - {{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) }} -

    -

    On this page

    - {{ .TableOfContents }} -
    -

    - {{ end }} - {{- with .Params.tags -}} -

    -

    Tags

    - [all] - {{- range . }} - {{- $tag := urlize . -}} - [{{ . }}] - {{- end }} -

    -
    -

    - {{- end }} +

    {{ end }} -{{ if isset .Params "series" }} -{{$related := where .Site.RegularPages ".Params.series" "eq" .Params.series }} +{{ if isset .Params "categories" }} +{{$related := where .Site.RegularPages ".Params.categories" "eq" .Params.categories }} {{- $relatedLimit := default 8 .Site.Params.numberOfRelatedPosts }} -

    More {{ .Params.series }}

    +

    More {{ .Params.categories }}

    diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 6ac089d..0b70a07 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -3,6 +3,19 @@

    {"powered_by": [{{- range $i, $link := .Site.Params.powerLinks }}{{ if $i }}, {{ end }}"{{ $link.title }}"{{ end }}]}
    <view source>

    + +{{ $jsToTop := resources.Get "js/back-to-top.js" | minify }} + + + + +{{ partial "search-index.html" .}} + + {{ if (findRE " diff --git a/layouts/partials/head.html b/layouts/partials/head.html index bcfc68b..9a2436a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -34,9 +34,9 @@ -{{ if .Site.Params.analytics }} - - +{{ if eq .Site.Params.analytics true }} + + {{ end }} diff --git a/layouts/partials/search-form.html b/layouts/partials/search-form.html new file mode 100644 index 0000000..d0c1455 --- /dev/null +++ b/layouts/partials/search-form.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/layouts/partials/search-index.html b/layouts/partials/search-index.html new file mode 100644 index 0000000..4276532 --- /dev/null +++ b/layouts/partials/search-index.html @@ -0,0 +1,17 @@ + +{{ $jsLunr := resources.Get "js/lunr.js" | minify }} + +{{ $jsSearch := resources.Get "js/search.js" | minify }} + \ No newline at end of file diff --git a/layouts/search/list.html b/layouts/search/list.html new file mode 100644 index 0000000..d51d35a --- /dev/null +++ b/layouts/search/list.html @@ -0,0 +1,9 @@ +{{ define "main" }} +{{ partial "search-form.html" . }} +
    +
      +
    • + What is it you desire? +
    • +
    +{{ end }} \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index 601059d..d62d2ed 100644 --- a/netlify.toml +++ b/netlify.toml @@ -6,14 +6,14 @@ [context.production] command = """ - hugo --minify + hugo npm i @torchlight-api/torchlight-cli npx torchlight """ [context.preview] command = """ - hugo --minify --environment preview + hugo --environment preview npm i @torchlight-api/torchlight-cli npx torchlight """ @@ -24,7 +24,7 @@ [context.drafts] command = """ - hugo --minify --environment drafts -D + hugo --environment drafts -D npm i @torchlight-api/torchlight-cli npx torchlight """ diff --git a/static/css/custom.css b/static/css/custom.css index 729876c..b37b41f 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1,3 +1,8 @@ +/* color overrides */ +:root { + --code: var(--base06); +} + /* override page max-width */ .page { max-width: 72rem; @@ -172,7 +177,7 @@ ul.pagination li { /* statuslol overrides */ .statuslol { - background: var(--inner-bg) !important; + background: var(--off-bg) !important; flex-direction:column } @@ -203,4 +208,129 @@ ul.pagination li { small[style^="opacity: .5"] { opacity: 1 !important; +} + +/* code overrides */ +pre, +code, +kbd, +samp { + color: var(--code); +} + +/* search box styling */ +form { + display: flex; + flex-direction: row; + border-radius: 0.25rem; + outline: 0.25rem solid var(--bg); + width: 240px; + transition: width .2s ease-in-out, outline .2s ease-in-out; +} + +input { + flex-grow: 2; + border: none; + background-color: var(--off-bg); + color: var(--off-fg); + height: 1.5rem; + border-radius: 0.25rem; + padding-left: 0.5rem; + font-family: var(--font-monospace); +} + +input:focus { + outline: none; +} + +form:focus-within { + outline: 1px solid var(--logo); + width: 100%; +} + +form button { + outline: none; + border: none; + background-color: var(--off-bg); + color: var(--link); +} + +/* tags list styling */ +.tagsArchive { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); + grid-gap: 0.5rem; + /* justify-content: center; */ + margin: 0.5rem 0; + +} + +.tagsArchive sup { + font-size: 0.75rem; + margin-left: 0.2rem; + margin-right: 0.5rem; +} + +.date { + font-size: 0.8rem; + color: var(--off-fg); +} + +/* blockquote styling */ +blockquote { + font-style: italic; + border-left: 0.25rem solid var(--logo); + padding-left: 0.25rem; +} + +/* tinylytics kudos styling*/ +.post_kudos { + display: flex; +} + +button.tinylytics_kudos { + border: 0; + background-color: transparent; + cursor: pointer; + display: flex; + color: var(--off-fg); + font-size: 1.2rem; + padding: 0; + transition: all .2s ease-in-out; +} + +button.tinylytics_kudos:hover { + transform: scale(1.1); + text-shadow: var(--off-fg) 0 0 1px; +} + +/* post front matter styling*/ +.frontmatter hr { + margin-bottom: 0rem; + margin-top: 0rem; +} + +.frontmatter h1 { + margin-top: 0rem; +} + +.frontmatter .label { + color: var(--off-fg); + font-size: 0.8rem; +} + +.frontmatter .title { + color: var(--fg); + font-weight: 600; + font-size: 1.1rem; +} + +.frontmatter table { + overflow-wrap: break-word; + margin-bottom: 0rem; +} + +.frontmatter_tags { + font-size: 0.8rem; + color: var(--off-fg); } \ No newline at end of file diff --git a/static/css/palettes/runtimeterror.css b/static/css/palettes/runtimeterror.css index 91bc2b8..3838a79 100644 --- a/static/css/palettes/runtimeterror.css +++ b/static/css/palettes/runtimeterror.css @@ -8,7 +8,7 @@ --base03: #585858; /* muted */ --base04: #abaaaa; /* off-fg */ --base05: #d8d8d8; /* fg */ - --base06: #e8e8e8; + --base06: #cfcfcf; /* code */ --base07: #5f8700; /* user prompt */ --base08: #ab4642; /* root prompt */ --base09: #dc9656; diff --git a/torchlight.config.js b/torchlight.config.js index 81c3bea..abdbd00 100644 --- a/torchlight.config.js +++ b/torchlight.config.js @@ -58,7 +58,9 @@ module.exports = { // appear, the file will be ignored. excludePatterns: [ '/node_modules/', - '/vendor/' + '/vendor/', + '/categories/', + '/tags/' ] } }