From 12537e0ce8d1b8b834192b9dd2056b159d615920 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Fri, 1 Nov 2024 19:49:14 +0200 Subject: [PATCH 01/11] Display title on Documentcloud.org embeds --- plugins/domains/documentcloud.org.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index 7d2b0cf50..c268aedc1 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -7,7 +7,6 @@ export default { "oembed-site", "canonical", "author", - "og-title", "og-image", "og-description" ], @@ -15,6 +14,15 @@ export default { // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame // https://www.documentcloud.org/help/api#oembed + getMeta: function(oembed, options) { + var title = options.getRequestOptions('documentcloud.title'); + if (title && oembed.title) { + return { + title: oembed.title + } + } + }, + getLink: function(url, oembed, options) { if (oembed.type === 'rich' && oembed.html) { // else: fallback to generic @@ -31,6 +39,7 @@ export default { if (!/DC\-note/.test(html) && !/DC\-embed(?:\-page)?/.test(html)) { var page = options.getRequestOptions('documentcloud.page', '1'); + var title = !!options.getRequestOptions('documentcloud.title', true); try { var iframe = oembed.getIframe(); @@ -51,6 +60,10 @@ export default { page: { label: CONFIG.L.page, value: parseInt (page) + }, + title: { + label: 'Show Title', + value: title } } } catch (ex) {} @@ -94,7 +107,6 @@ export default { 'og-description', 'author', 'canonical', - 'og-title', 'og-image' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', From 743632d4885d88a370f14a5b52eb35e6950932dc Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Fri, 1 Nov 2024 20:10:19 +0200 Subject: [PATCH 02/11] Option title to allowTitle as it is boolean, use og instead of oembed --- plugins/domains/documentcloud.org.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index c268aedc1..eaa67e647 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -14,11 +14,11 @@ export default { // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame // https://www.documentcloud.org/help/api#oembed - getMeta: function(oembed, options) { - var title = options.getRequestOptions('documentcloud.title'); - if (title && oembed.title) { + getMeta: function(og, options) { + var allowTitle = options.getRequestOptions('documentcloud.allowTitle'); + if (allowTitle && og.title) { return { - title: oembed.title + title: og.title } } }, @@ -39,7 +39,7 @@ export default { if (!/DC\-note/.test(html) && !/DC\-embed(?:\-page)?/.test(html)) { var page = options.getRequestOptions('documentcloud.page', '1'); - var title = !!options.getRequestOptions('documentcloud.title', true); + var allowTitle = !!options.getRequestOptions('documentcloud.allowTitle'); try { var iframe = oembed.getIframe(); @@ -61,9 +61,9 @@ export default { label: CONFIG.L.page, value: parseInt (page) }, - title: { + allowTitle: { label: 'Show Title', - value: title + value: allowTitle } } } catch (ex) {} From 2b40fed34a90e58d10993412af331633d1887c90 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Mon, 4 Nov 2024 15:31:06 +0200 Subject: [PATCH 03/11] documentcloud.org title param move back to previous naming and default to false --- plugins/domains/documentcloud.org.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index eaa67e647..e2f83ac64 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -8,20 +8,13 @@ export default { "canonical", "author", "og-image", + "og-title", "og-description" ], // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame // https://www.documentcloud.org/help/api#oembed - getMeta: function(og, options) { - var allowTitle = options.getRequestOptions('documentcloud.allowTitle'); - if (allowTitle && og.title) { - return { - title: og.title - } - } - }, getLink: function(url, oembed, options) { @@ -39,7 +32,7 @@ export default { if (!/DC\-note/.test(html) && !/DC\-embed(?:\-page)?/.test(html)) { var page = options.getRequestOptions('documentcloud.page', '1'); - var allowTitle = !!options.getRequestOptions('documentcloud.allowTitle'); + var title = options.getRequestOptions('documentcloud.title', false); try { var iframe = oembed.getIframe(); @@ -61,9 +54,9 @@ export default { label: CONFIG.L.page, value: parseInt (page) }, - allowTitle: { - label: 'Show Title', - value: allowTitle + title: { + label: 'Show title', + value: title } } } catch (ex) {} @@ -107,7 +100,8 @@ export default { 'og-description', 'author', 'canonical', - 'og-image' + 'og-image', + 'og-title' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8.html#document/p2/a486265', From 51043f1c518d09e049a3815f5db0c967f72a6128 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Mon, 4 Nov 2024 15:32:40 +0200 Subject: [PATCH 04/11] cleanup --- plugins/domains/documentcloud.org.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index e2f83ac64..c4f38bdf2 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -7,15 +7,14 @@ export default { "oembed-site", "canonical", "author", - "og-image", "og-title", + "og-image", "og-description" ], // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame // https://www.documentcloud.org/help/api#oembed - getLink: function(url, oembed, options) { if (oembed.type === 'rich' && oembed.html) { // else: fallback to generic @@ -100,8 +99,8 @@ export default { 'og-description', 'author', 'canonical', - 'og-image', - 'og-title' + 'og-title', + 'og-image' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8.html#document/p2/a486265', From 498241aa1432692ef634389b80cd6fda5cce97e8 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Mon, 4 Nov 2024 16:08:36 +0200 Subject: [PATCH 05/11] Use both `og` and `oembed` title --- plugins/domains/documentcloud.org.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index c4f38bdf2..b63107972 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -9,7 +9,8 @@ export default { "author", "og-title", "og-image", - "og-description" + "og-description", + "oembed-title" ], // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame @@ -100,7 +101,8 @@ export default { 'author', 'canonical', 'og-title', - 'og-image' + 'og-image', + 'oembed-title' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8.html#document/p2/a486265', From ad618bae622ccf292a2f1ad835b85c400a071186 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Mon, 4 Nov 2024 16:18:13 +0200 Subject: [PATCH 06/11] Revert "Use both `og` and `oembed` title" This reverts commit 498241aa1432692ef634389b80cd6fda5cce97e8. --- plugins/domains/documentcloud.org.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index b63107972..c4f38bdf2 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -9,8 +9,7 @@ export default { "author", "og-title", "og-image", - "og-description", - "oembed-title" + "og-description" ], // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame @@ -101,8 +100,7 @@ export default { 'author', 'canonical', 'og-title', - 'og-image', - 'oembed-title' + 'og-image' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8.html#document/p2/a486265', From a20c1b0880d04487c7f3c1a52f42e6f4c193babb Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Mon, 4 Nov 2024 20:00:21 +0200 Subject: [PATCH 07/11] Reapply "Use both `og` and `oembed` title" This reverts commit ad618bae622ccf292a2f1ad835b85c400a071186. --- plugins/domains/documentcloud.org.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index c4f38bdf2..b63107972 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -9,7 +9,8 @@ export default { "author", "og-title", "og-image", - "og-description" + "og-description", + "oembed-title" ], // plugin is required to add aspect-ratio and with this fix embeds when used inside iFrame @@ -100,7 +101,8 @@ export default { 'author', 'canonical', 'og-title', - 'og-image' + 'og-image', + 'oembed-title' ]}, 'https://www.documentcloud.org/documents/73991-day-three-documents', 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8.html#document/p2/a486265', From c9040b239b802df7f157e7a52821bb94cac22258 Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Tue, 5 Nov 2024 20:22:27 +0200 Subject: [PATCH 08/11] propagate title param to iframe src --- plugins/domains/documentcloud.org.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index b63107972..0874566ef 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -38,6 +38,10 @@ export default { var iframe = oembed.getIframe(); var href = iframe.src; + var uri = new URL(href); + uri.searchParams.append("title", title ? '1': '0'); + href = uri.toString(); + if (page && page !== '1') { if (href) { href += '#document/p' + page; From 6ed9647d247e840a78dc3b86e7dbfcec52d552fe Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Wed, 6 Nov 2024 09:49:12 +0200 Subject: [PATCH 09/11] Append param only if title is true. --- plugins/domains/documentcloud.org.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index 0874566ef..5aff2ee6a 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -32,15 +32,17 @@ export default { if (!/DC\-note/.test(html) && !/DC\-embed(?:\-page)?/.test(html)) { var page = options.getRequestOptions('documentcloud.page', '1'); - var title = options.getRequestOptions('documentcloud.title', false); + var title = !!options.getRequestOptions('documentcloud.title', false); try { var iframe = oembed.getIframe(); var href = iframe.src; - var uri = new URL(href); - uri.searchParams.append("title", title ? '1': '0'); - href = uri.toString(); + if (title) { + var uri = new URL(href); + uri.searchParams.append("title", '1'); + href = uri.toString(); + } if (page && page !== '1') { if (href) { From 1eea7e7ff6e385d7565acb8705b7e21784e7047e Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Wed, 6 Nov 2024 09:54:34 +0200 Subject: [PATCH 10/11] use internal util and add test url with title param --- plugins/domains/documentcloud.org.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index 5aff2ee6a..6321b3169 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -36,13 +36,7 @@ export default { try { var iframe = oembed.getIframe(); - var href = iframe.src; - - if (title) { - var uri = new URL(href); - uri.searchParams.append("title", '1'); - href = uri.toString(); - } + var href = title ? iframe.replaceQuerystring({ title: 1 }) : iframe.src; if (page && page !== '1') { if (href) { @@ -116,6 +110,7 @@ export default { // 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8/pages/2.html', 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal.html', 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal', + "https://www.documentcloud.org/documents/1995734-freddie-gray-charging-documents.html?_title=1", // 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal/pages/2.html', "https://www.documentcloud.org/documents/20059068-the-mueller-report#document/p17/a2001254", "https://www.documentcloud.org/documents/20059068-the-mueller-report", From 2e1cc645d2ea82531a257ebcf70c16d85a37e2fc Mon Sep 17 00:00:00 2001 From: garmoncheg Date: Wed, 6 Nov 2024 16:25:41 +0200 Subject: [PATCH 11/11] Remove unused test --- plugins/domains/documentcloud.org.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/domains/documentcloud.org.js b/plugins/domains/documentcloud.org.js index 6321b3169..d4bcd1f1d 100644 --- a/plugins/domains/documentcloud.org.js +++ b/plugins/domains/documentcloud.org.js @@ -110,7 +110,6 @@ export default { // 'https://www.documentcloud.org/documents/5766398-ASRS-Reports-for-737-max8/pages/2.html', 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal.html', 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal', - "https://www.documentcloud.org/documents/1995734-freddie-gray-charging-documents.html?_title=1", // 'https://www.documentcloud.org/documents/7203159-Joaqu%C3%ADn-El-Chapo-Guzm%C3%A1n-Appeal/pages/2.html', "https://www.documentcloud.org/documents/20059068-the-mueller-report#document/p17/a2001254", "https://www.documentcloud.org/documents/20059068-the-mueller-report",