From 103ba614364fc744f870ac072f5cc4250b3bc418 Mon Sep 17 00:00:00 2001 From: meelahme Date: Sat, 28 Dec 2024 14:59:12 -0800 Subject: [PATCH 1/5] closing tag at line 190 --- .../cloud-dedicated/reference/client-libraries/v3/python.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md index f689e00a5..82a1faef6 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md @@ -182,8 +182,6 @@ client = InfluxDBClient3(host=f"{{< influxdb/host >}}", database=f"DATABASE_NAME", token=f"DATABASE_TOKEN") ``` - - {{% /code-placeholders %}} Replace the following: From 326c9827c3cb581415f84d1d73e40e7ab69e7a70 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Mon, 30 Dec 2024 11:44:21 -0600 Subject: [PATCH 2/5] fix(client-lib): commented code block for test setup #5711 - Add CONTRIBUTING.md step for building the influxdata:docs-pytest image before running tests. --- CONTRIBUTING.md | 11 +++++++++++ .../reference/client-libraries/v3/python.md | 12 ++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 031707ba1..aad3f3e96 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,17 @@ Install [Docker](https://docs.docker.com/get-docker/) for your system. docs-v2 includes Docker configurations (`compose.yaml` and Dockerfiles) for running the Vale style linter and tests for code blocks (Shell, Bash, and Python) in Markdown files. +#### Build the test dependency image + +After you have installed Docker, run the following command to build the test +dependency image, `influxdata:docs-pytest`. +The tests defined in `compose.yaml` use the dependencies and execution +environment from this image. + +```bash +docker build -t influxdata:docs-pytest -f Dockerfile.pytest . +``` + ### Run the documentation locally (optional) To run the documentation locally, follow the instructions provided in the README. diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md index 82a1faef6..50996bd87 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md @@ -17,9 +17,9 @@ related: list_code_example: > ```python - Example: Writing and querying data + # Example: Write and que data - # The following example demonstrates how to write sensor data into influxDB + # Write sensor data into influxDB # and retrieve data from the last 90 days for analysis. @@ -171,10 +171,13 @@ Given that `write_client_options` isn't specified, the client uses the default [ {{% code-placeholders "DATABASE_(NAME|TOKEN)" %}} - - + + ```python from influxdb_client_3 import InfluxDBClient3 @@ -182,6 +185,7 @@ client = InfluxDBClient3(host=f"{{< influxdb/host >}}", database=f"DATABASE_NAME", token=f"DATABASE_TOKEN") ``` + {{% /code-placeholders %}} Replace the following: From 868a7528deb856a4bd442a9ed891347557e105dd Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Mon, 30 Dec 2024 13:08:03 -0600 Subject: [PATCH 3/5] Update content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md --- .../cloud-dedicated/reference/client-libraries/v3/python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md index 82a1faef6..2a8b5da84 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md @@ -43,7 +43,7 @@ list_code_example: > --- The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python) -integrates {{% product-name %}} write and query operations with Python scripts and applications. +integrates {{% product-name %}} write and query operations with Python scripts and applications. InfluxDB client libraries provide configurable batch writing of data to {{% product-name %}}. Client libraries can be used to construct line protocol data, transform data from other formats From c97e9b1592f8ea1bc4d1beaf525e8f02903c10d6 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Tue, 31 Dec 2024 09:40:44 -0600 Subject: [PATCH 4/5] Update content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md --- .../cloud-dedicated/reference/client-libraries/v3/python.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md index c7c972f7a..9c7afbbfe 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md @@ -17,7 +17,7 @@ related: list_code_example: > ```python - # Example: Write and que data + # Example: Write and query data # Write sensor data into influxDB From 8dbd485854b0209feef23b73ced101a42698ca3b Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 31 Dec 2024 11:04:23 -0700 Subject: [PATCH 5/5] port cookies to local storage (#5725) --- assets/js/js.cookie.js | 165 --------------------- assets/js/{cookies.js => local-storage.js} | 111 +++++++------- layouts/partials/header/javascript.html | 5 +- 3 files changed, 55 insertions(+), 226 deletions(-) delete mode 100644 assets/js/js.cookie.js rename assets/js/{cookies.js => local-storage.js} (58%) diff --git a/assets/js/js.cookie.js b/assets/js/js.cookie.js deleted file mode 100644 index 9a0945ed8..000000000 --- a/assets/js/js.cookie.js +++ /dev/null @@ -1,165 +0,0 @@ -/*! - * JavaScript Cookie v2.2.0 - * https://github.com/js-cookie/js-cookie - * - * Copyright 2006, 2015 Klaus Hartl & Fagner Brack - * Released under the MIT license - */ -;(function (factory) { - var registeredInModuleLoader = false; - if (typeof define === 'function' && define.amd) { - define(factory); - registeredInModuleLoader = true; - } - if (typeof exports === 'object') { - module.exports = factory(); - registeredInModuleLoader = true; - } - if (!registeredInModuleLoader) { - var OldCookies = window.Cookies; - var api = window.Cookies = factory(); - api.noConflict = function () { - window.Cookies = OldCookies; - return api; - }; - } -}(function () { - function extend () { - var i = 0; - var result = {}; - for (; i < arguments.length; i++) { - var attributes = arguments[ i ]; - for (var key in attributes) { - result[key] = attributes[key]; - } - } - return result; - } - - function init (converter) { - function api (key, value, attributes) { - var result; - if (typeof document === 'undefined') { - return; - } - - // Write - - if (arguments.length > 1) { - attributes = extend({ - path: '/' - }, api.defaults, attributes); - - if (typeof attributes.expires === 'number') { - var expires = new Date(); - expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); - attributes.expires = expires; - } - - // We're using "expires" because "max-age" is not supported by IE - attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; - - try { - result = JSON.stringify(value); - if (/^[\{\[]/.test(result)) { - value = result; - } - } catch (e) {} - - if (!converter.write) { - value = encodeURIComponent(String(value)) - .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); - } else { - value = converter.write(value, key); - } - - key = encodeURIComponent(String(key)); - key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); - key = key.replace(/[\(\)]/g, escape); - - var stringifiedAttributes = ''; - - for (var attributeName in attributes) { - if (!attributes[attributeName]) { - continue; - } - stringifiedAttributes += '; ' + attributeName; - if (attributes[attributeName] === true) { - continue; - } - stringifiedAttributes += '=' + attributes[attributeName]; - } - return (document.cookie = key + '=' + value + stringifiedAttributes); - } - - // Read - - if (!key) { - result = {}; - } - - // To prevent the for loop in the first place assign an empty array - // in case there are no cookies at all. Also prevents odd result when - // calling "get()" - var cookies = document.cookie ? document.cookie.split('; ') : []; - var rdecode = /(%[0-9A-Z]{2})+/g; - var i = 0; - - for (; i < cookies.length; i++) { - var parts = cookies[i].split('='); - var cookie = parts.slice(1).join('='); - - if (!this.json && cookie.charAt(0) === '"') { - cookie = cookie.slice(1, -1); - } - - try { - var name = parts[0].replace(rdecode, decodeURIComponent); - cookie = converter.read ? - converter.read(cookie, name) : converter(cookie, name) || - cookie.replace(rdecode, decodeURIComponent); - - if (this.json) { - try { - cookie = JSON.parse(cookie); - } catch (e) {} - } - - if (key === name) { - result = cookie; - break; - } - - if (!key) { - result[name] = cookie; - } - } catch (e) {} - } - - return result; - } - - api.set = api; - api.get = function (key) { - return api.call(api, key); - }; - api.getJSON = function () { - return api.apply({ - json: true - }, [].slice.call(arguments)); - }; - api.defaults = {}; - - api.remove = function (key, attributes) { - api(key, '', extend(attributes, { - expires: -1 - })); - }; - - api.withConverter = init; - - return api; - } - - return init(function () {}); -})); diff --git a/assets/js/cookies.js b/assets/js/local-storage.js similarity index 58% rename from assets/js/cookies.js rename to assets/js/local-storage.js index 456794183..ea01f114a 100644 --- a/assets/js/cookies.js +++ b/assets/js/local-storage.js @@ -1,46 +1,41 @@ /* - This represents an API for managing cookies for the InfluxData documentation. - It uses the Cookies.js library to store data as session cookies. - This is done to comply with cookie privacy laws and limit the cookies used - to manage the user experience throughout the InfluxData documentation. - - These functions manage the following InfluxDB cookies + This represents an API for managing user and client-side settings for the + InfluxData documentation. It uses the local browser storage. + + These functions manage the following InfluxDB settings: - influxdata_docs_preferences: Docs UI/UX-related preferences (obj) - influxdata_docs_urls: User-defined InfluxDB URLs for each product (obj) - influxdata_docs_notifications: - messages: Messages (data/notifications.yaml) that have been seen (array) - callouts: Feature callouts that have been seen (array) - - influxdata_docs_ported: Temporary cookie to help port old cookies to new structure */ -// Prefix for all InfluxData docs cookies -const cookiePrefix = 'influxdata_docs_'; +// Prefix for all InfluxData docs local storage +const storagePrefix = 'influxdata_docs_'; /* - Initialize a cookie with a default value. + Initialize data in local storage with a default value. */ -initializeCookie = (cookieName, defaultValue) => { - fullCookieName = cookiePrefix + cookieName; +initializeLocalStorage = (storageKey, defaultValue) => { + fullStorageKey = storagePrefix + storageKey; - // Check if the cookie exists before initializing the cookie - if (Cookies.get(fullCookieName) === undefined) { - Cookies.set(fullCookieName, defaultValue); + // Check if the data exists before initializing the data + if (localStorage.getItem(fullStorageKey) === null) { + localStorage.setItem(fullStorageKey, defaultValue); } }; -// Initialize all InfluxData docs cookies with defaults - /* //////////////////////////////////////////////////////////////////////////////// ////////////////////////// INFLUXDATA DOCS PREFERENCES ///////////////////////// //////////////////////////////////////////////////////////////////////////////// */ -const prefCookieName = cookiePrefix + 'preferences'; +const prefStorageKey = storagePrefix + 'preferences'; // Default preferences -var defaultPref = { +var defaultPrefObj = { api_lib: null, influxdb_url: 'cloud', sidebar_state: 'open', @@ -50,35 +45,35 @@ var defaultPref = { }; /* - Retrieve a preference from the preference cookie. - If the cookie doesn't exist, initialize it with default values. + Retrieve a preference from the preference key. + If the key doesn't exist, initialize it with default values. */ getPreference = prefName => { - // Initialize the preference cookie if it doesn't already exist - if (Cookies.get(prefCookieName) === undefined) { - initializeCookie('preferences', defaultPref); + // Initialize preference data if it doesn't already exist + if (localStorage.getItem(prefStorageKey) === null) { + initializeLocalStorage('preferences', JSON.stringify(defaultPrefObj)); } - // Retrieve and parse the cookie as JSON - prefString = Cookies.get(prefCookieName); + // Retrieve and parse preferences as JSON + prefString = localStorage.getItem(prefStorageKey); prefObj = JSON.parse(prefString); // Return the value of the specified preference return prefObj[prefName]; }; -// Set a preference in the preferences cookie +// Set a preference in the preferences key setPreference = (prefID, prefValue) => { - var prefString = Cookies.get(prefCookieName); + var prefString = localStorage.getItem(prefStorageKey); let prefObj = JSON.parse(prefString); prefObj[prefID] = prefValue; - Cookies.set(prefCookieName, prefObj); + localStorage.setItem(prefStorageKey, JSON.stringify(prefObj)); }; // Return an object containing all preferences -getPreferences = () => JSON.parse(Cookies.get(prefCookieName)); +getPreferences = () => JSON.parse(localStorage.getItem(prefStorageKey)); /* //////////////////////////////////////////////////////////////////////////////// @@ -86,7 +81,7 @@ getPreferences = () => JSON.parse(Cookies.get(prefCookieName)); //////////////////////////////////////////////////////////////////////////////// */ -const urlCookieName = cookiePrefix + 'urls'; +const urlStorageKey = storagePrefix + 'urls'; // Default URLs per product var defaultUrls = { @@ -97,8 +92,8 @@ var defaultUrls = { clustered: 'cluster-host.com', }; -// Defines the default urls cookie value -var defaultUrlsCookie = { +// Defines the default urls value +var defaultUrlsObj = { oss: defaultUrls.oss, cloud: defaultUrls.cloud, serverless: defaultUrls.serverless, @@ -112,25 +107,25 @@ var defaultUrlsCookie = { custom: '', }; -// Return an object that contains all InfluxDB urls stored in the urls cookie +// Return an object that contains all InfluxDB urls stored in the urls key getInfluxDBUrls = () => { - // Initialize the urls cookie if it doesn't already exist - if (Cookies.get(urlCookieName) === undefined) { - initializeCookie('urls', defaultUrlsCookie); + // Initialize urls data if it doesn't already exist + if (localStorage.getItem(urlStorageKey) === null) { + initializeLocalStorage('urls', JSON.stringify(defaultUrlsObj)); } - return JSON.parse(Cookies.get(urlCookieName)); + return JSON.parse(localStorage.getItem(urlStorageKey)); }; // Get the current or previous URL for a specific product or a custom url getInfluxDBUrl = product => { - // Initialize the urls cookie if it doesn't already exist - if (Cookies.get(urlCookieName) === undefined) { - initializeCookie('urls', defaultUrlsCookie); + // Initialize urls data if it doesn't already exist + if (localStorage.getItem(urlStorageKey) === null) { + initializeLocalStorage('urls', JSON.stringify(defaultUrlsObj)); } - // Retrieve and parse the cookie as JSON - urlsString = Cookies.get(urlCookieName); + // Retrieve and parse the URLs as JSON + urlsString = localStorage.getItem(urlStorageKey); urlsObj = JSON.parse(urlsString); // Return the URL of the specified product @@ -138,27 +133,27 @@ getInfluxDBUrl = product => { }; /* - Set multiple product URLs in the urls cookie. + Set multiple product URLs in the urls key. Input should be an object where the key is the product and the value is the URL to set for that product. */ setInfluxDBUrls = updatedUrlsObj => { - var urlsString = Cookies.get(urlCookieName); + var urlsString = localStorage.getItem(urlStorageKey); let urlsObj = JSON.parse(urlsString); newUrlsObj = { ...urlsObj, ...updatedUrlsObj }; - Cookies.set(urlCookieName, newUrlsObj); + localStorage.setItem(urlStorageKey, JSON.stringify(newUrlsObj)); }; -// Set an InfluxDB URL to an empty string in the urls cookie +// Set an InfluxDB URL to an empty string in the urls key removeInfluxDBUrl = product => { - var urlsString = Cookies.get(urlCookieName); + var urlsString = localStorage.getItem(urlStorageKey); let urlsObj = JSON.parse(urlsString); urlsObj[product] = ''; - Cookies.set(urlCookieName, urlsObj); + localStorage.setItem(urlStorageKey, JSON.stringify(urlsObj)); }; /* @@ -167,25 +162,25 @@ removeInfluxDBUrl = product => { //////////////////////////////////////////////////////////////////////////////// */ -const notificationCookieName = cookiePrefix + 'notifications'; +const notificationStorageKey = storagePrefix + 'notifications'; // Default notifications -var defaultNotifications = { +var defaultNotificationsObj = { messages: [], callouts: [], }; getNotifications = () => { - // Initialize the notifications cookie if it doesn't already exist - if (Cookies.get(notificationCookieName) === undefined) { - initializeCookie('notifications', defaultNotifications); + // Initialize notifications data if it doesn't already exist + if (localStorage.getItem(notificationStorageKey) === null) { + initializeLocalStorage('notifications', JSON.stringify(defaultNotificationsObj)); } - // Retrieve and parse the cookie as JSON - notificationString = Cookies.get(notificationCookieName); + // Retrieve and parse the notifications data as JSON + notificationString = localStorage.getItem(notificationStorageKey); notificationObj = JSON.parse(notificationString); - // Return the value of the specified preference + // Return the notifications object return notificationObj; }; @@ -222,5 +217,5 @@ setNotificationAsRead = (notificationID, notificationType) => { readNotifications.push(notificationID); notificationsObj[notificationType + 's'] = readNotifications; - Cookies.set(notificationCookieName, notificationsObj); + localStorage.setItem(notificationStorageKey, JSON.stringify(notificationsObj)); }; diff --git a/layouts/partials/header/javascript.html b/layouts/partials/header/javascript.html index f257221be..b763b8ef1 100644 --- a/layouts/partials/header/javascript.html +++ b/layouts/partials/header/javascript.html @@ -1,9 +1,8 @@ {{ $jquery := resources.Get "js/jquery-3.5.0.min.js" }} -{{ $cookies := resources.Get "js/js.cookie.js" }} -{{ $docsCookies := resources.Get "js/cookies.js" }} +{{ $localStorage := resources.Get "js/local-storage.js" }} {{ $themes := resources.Get "js/docs-themes.js" }} {{ $sidebar := resources.Get "js/sidebar-toggle.js" }} -{{ $headerjs := slice $jquery $cookies $docsCookies $themes $sidebar | resources.Concat "js/header.bundle.js" | resources.Fingerprint }} +{{ $headerjs := slice $jquery $localStorage $themes $sidebar | resources.Concat "js/header.bundle.js" | resources.Fingerprint }}