Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opengraph improvements #685

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
3dd5ec3
Empty-Commit
Jun 28, 2023
9df6b3f
changelog
Jun 28, 2023
ad8cc22
title
Jun 28, 2023
45fa429
link image
Jun 28, 2023
5f06143
removed image
Jun 28, 2023
496fb92
added image
Jun 28, 2023
03c6ae8
Merge branch 'ploomber:master' into opengraph-improvements
anupam-tiwari Jun 30, 2023
1373cab
local file test
Jun 30, 2023
c8af7e9
image change
Jun 30, 2023
8939465
image
Jun 30, 2023
70b0b93
image
Jun 30, 2023
be18433
image 2
Jun 30, 2023
e52aab3
img3
Jun 30, 2023
28bba32
testing static image
Jul 3, 2023
4ce7fef
static
Jul 3, 2023
6b826f8
added alt image
Jul 3, 2023
702575c
comma
Jul 3, 2023
bf2270b
test alt
Jul 3, 2023
265990b
added alt text
Jul 3, 2023
4e5051e
added extension
Jul 5, 2023
69d2fd8
resolved conflict
Jul 5, 2023
13bc716
added url
Jul 5, 2023
e6c0381
import error
Jul 5, 2023
c505fd5
error
Jul 5, 2023
b5ea78f
resolve error
Jul 5, 2023
549174d
test
Jul 6, 2023
248fbbb
added link
Jul 6, 2023
a84ca33
removed slash
Jul 6, 2023
0811d69
removed typo
Jul 6, 2023
f301281
added files
Jul 10, 2023
1c09baf
added img
Jul 10, 2023
b760914
added file
Jul 12, 2023
1460b07
Empty-Commit
Jul 14, 2023
ec8a264
Empty-Commit
Jul 15, 2023
3eed54c
commit
Jul 15, 2023
d6137cf
commit
Jul 15, 2023
0ba3a39
commit
Jul 15, 2023
5cc0258
commit
Jul 15, 2023
3e6e3d7
Merge branch 'ploomber:master' into master
anupam-tiwari Jul 19, 2023
4925947
Merge branch 'ploomber:master' into master
anupam-tiwari Jul 25, 2023
0ff160d
Merge branch 'ploomber:master' into master
anupam-tiwari Jul 26, 2023
0e497db
Merge branch 'ploomber:master' into master
anupam-tiwari Jul 28, 2023
d6a0985
commit
Jul 28, 2023
c188c66
commit
Jul 28, 2023
9ebfd08
commit
Jul 28, 2023
fcdbd8e
commit
Jul 28, 2023
ba1bd90
commit
Jul 28, 2023
9530d8f
commit
Jul 28, 2023
483d28b
commit
Jul 28, 2023
611f0a5
commit
Jul 28, 2023
913bd12
Merge branch 'ploomber:master' into master
anupam-tiwari Jul 30, 2023
e9fa4da
commit
Jul 30, 2023
0b4963d
commit
Jul 30, 2023
efbc459
commit
Jul 30, 2023
388cbc7
commit
Jul 30, 2023
4998879
commit
Jul 30, 2023
78fc75f
commit
Jul 30, 2023
847130c
commit
Jul 30, 2023
3a251c9
commit
Jul 30, 2023
cc15f75
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 2, 2023
9153b59
commit
Aug 2, 2023
3389e5a
commit
Aug 2, 2023
33b0de1
commit
Aug 2, 2023
584c709
commit
Aug 2, 2023
e22089b
commit
Aug 2, 2023
37bc212
commit
Aug 2, 2023
9d88696
commit
Aug 2, 2023
f686191
commit
Aug 2, 2023
e5aa10f
commit
Aug 2, 2023
25eb0cc
commit
Aug 2, 2023
73244db
commit
Aug 2, 2023
e9f2cbd
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 4, 2023
df49c84
Empty-Commit
Aug 4, 2023
d152cfc
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 5, 2023
37c6fee
commit
Aug 5, 2023
14354c4
commit
Aug 5, 2023
1c2963f
commit
Aug 5, 2023
e3a37f6
commit
Aug 5, 2023
f9e8109
commit
Aug 5, 2023
d99e756
commit
Aug 5, 2023
bb04fed
commit
Aug 7, 2023
a5602af
commit
Aug 7, 2023
054bbc0
commit
Aug 7, 2023
33fd15d
updated based on review
Aug 8, 2023
9315d2d
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 10, 2023
8e7056e
merging
Aug 10, 2023
0cbc64e
created drawio folder called asset folder
Aug 10, 2023
2990c22
testing og:image:alt
Aug 10, 2023
c70b090
lint/format
Aug 10, 2023
c57fad1
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 11, 2023
1efe85f
added og:image:alt
Aug 11, 2023
b36a43c
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 16, 2023
0977b26
conflict
Aug 16, 2023
1e43716
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 17, 2023
3cafc11
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 22, 2023
e4eb068
conflict
Aug 22, 2023
f12c355
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 23, 2023
4e44524
conflict
Aug 23, 2023
8d275cd
exp
Aug 23, 2023
1aefd17
exp
Aug 23, 2023
ef5a7a1
null title
Aug 23, 2023
f9f9b1b
doc
Aug 23, 2023
272a9da
doc
Aug 24, 2023
cc092b4
doc
Aug 24, 2023
c38adf0
doc
Aug 24, 2023
e74f4ec
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 25, 2023
3903870
conflict
Aug 26, 2023
1ba63e0
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 30, 2023
28e9057
conflict
Aug 30, 2023
e23548a
test
Aug 30, 2023
74cc883
test
Aug 30, 2023
97d3ca0
test
Aug 30, 2023
80ce25a
test
Aug 30, 2023
09cf684
Merge branch 'ploomber:master' into master
anupam-tiwari Aug 30, 2023
0ff9d04
confict
Aug 30, 2023
8c51c39
Merge branch 'ploomber:master' into master
anupam-tiwari Sep 5, 2023
d0b5e80
Merge branch 'ploomber:master' into master
anupam-tiwari Sep 6, 2023
6849aae
conflict
anupam-tiwari Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [Doc] Add chDB integration tutorial
* [Doc] Clarify the use of `pyproject.toml` and `connections.ini` in documentations (#850)
* [Fix] Fix result not displayed when `SUMMARIZE` argument is used in duckdb with a sqlalchemy connection (#836)
* [Doc] Opengraph/Sphinxext-opengraph Integration and Optimization for Social Media link Sharing (#253)

## 0.10.1 (2023-08-30)

Expand Down
Binary file added doc/_static/duckdb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/html-meta-template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions doc/assets/duckdb.drawio

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions doc/assets/html-meta-template.drawio

Large diffs are not rendered by default.

File renamed without changes.
113 changes: 113 additions & 0 deletions doc/community/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,116 @@ As you can see, output results are different
From duckdb dialect: `'SELECT TO_TIMESTAMP(1618088028295)'`

From sqlite dialect: `'SELECT UNIX_TO_TIME(1618088028295)'`

## Enhancing Social Media/SEO Previews: Integrating Open Graph Tags

Open Graph tags hold metadata (such as images and descriptions) that influence how links are presented on social media platforms and in search engine results. [Sphinxext-opengraph](https://sphinxext-opengraph.readthedocs.io/en/latest/) extension package enables us to add/modify Open Graph Tags.

### Tab titles

To change the tab title of the entire website modify the html_title tag in the conf file in the doc folder. Here are a few cases:

html_title = "JupySQL documentation" # case 1: Sets to "JupySQL documentation" as title
html_title = "" # case 2: Empty title
#case 3: no html_title tag will result in default "Python documentation" title by Sphinx

### Page titles

#### Individual pages

To change the title of individual page add the og:title tag on top of targeted markdown file

```
---
og:image: /en/685/_static/duckdb.png
og:image:alt: 'Better SQL in Jupyter. 📊.'
og:description: 'Duckdb'
og:title: 'Duckdb title' # Title tag
jupytext:
notebook_metadata_filter: myst
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
myst:
html_meta:
description lang=en: Use DuckDB from Jupyter using JupySQL
keywords: jupyter, sql, jupysql, duckdb, plotting
property=og:locale: en_US
---

# DuckDB # default title
```
By default, the title of the individual page will be the first header on the markdown page. In our case, it's 'DuckDB'. Here are some other cases:

# case 1: No og:title tag, the page title will be "DuckDB"

og:title: '' # case 2: Page title will be empty

og:title: 5 # case 3: Page title will be "5"

og:title: # case 4: Page title will be "null"

### Page Image

#### Entire website

Open Graph image tags control how links are previewed on social media sites. By default, the image is set to null. To add an Open Graph image, add/modify the ogp_image and ogp_image_alt tags in the conf file inside the doc folder. These images will than become default image for all pages.

ogp_image: "/en/685/_static/html-meta-template.png" # takes a URL link to the image, case 1: If images are hosted in the repo*

ogp_image: "url goes here" # case 2: Any other image on the web

ogp_image_alt:"Better SQL in Jupyter. 📊."

*The Sphinxext-opengraph extension creates an og:image link by combining ogp_site_url and ogp_image. The ogp_site_url tag takes the site url as default, in our case url: "https://jupysql.ploomber.io", thus the final image link will be: https://jupysql.ploomber.io + /en/685/_static/html-meta-template.png, ogp_site_url can be given a different value by adding the tag in the conf file.

ogp_site_url = "https://jupysql.ploomber.io"

#### Individual page

The Sphinxext-opengraph package provides us with tags to enable Open Graph tags on individual pages. To add an Open Graph Image, include the og:image tag at the top of the individual markdown file. This will ensure that the image is considered and will override the default og:image for that particular page.

```
---
og:image: /en/685/_static/duckdb.png # Open Graph image for this page
og:image:alt: 'Better SQL in Jupyter. 📊.'
og:description: 'Duckdb'
og:title: 'Duckdb title' # Title tag
jupytext:
notebook_metadata_filter: myst
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.14.7
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
myst:
html_meta:
description lang=en: Use DuckDB from Jupyter using JupySQL
keywords: jupyter, sql, jupysql, duckdb, plotting
property=og:locale: en_US
---

# DuckDB # default title
```

##### Hosting images in the repo

In many cases, we won't be using external links as og:image; instead, we would use images from our repo. In this case, we will store all the static images in the "_static" folder under the doc folder. This will allow us to access them after the build at the "~/build/_static/" path.

Things to keep in mind:

- Image file should be under 8 MB

- The recommended size for og:image is 1,200 x 630 pixels. Use "https://www.drawio.com/" to create the image and store it in the "_static" folder. Also, save the drawio file in the "assets" folder under the doc folder.

- Double-check the image after it is hosted in your browser to ensure that it is accessible.
4 changes: 4 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"sphinx.ext.autosummary",
"matplotlib.sphinxext.plot_directive",
"sphinx_jupyterbook_latex",
"sphinxext.opengraph",
]
external_toc_exclude_missing = False
external_toc_path = "_toc.yml"
Expand All @@ -55,6 +56,7 @@
html_logo = "square-no-bg-small.png"
html_sourcelink_suffix = ""
html_theme = "sphinx_book_theme"
html_title = "JupySQL documentation"
html_theme_options = {
"launch_buttons": {
"notebook_interface": "jupyterlab",
Expand Down Expand Up @@ -99,6 +101,8 @@
suppress_warnings = ["misc.highlighting_failure"]
use_jupyterbook_latex = True
use_multitoc_numbering = True
ogp_image = "/en/685/_static/html-meta-template.png"
ogp_image_alt = "Better SQL in Jupyter. 📊."


# Adding Algolia search to jupyter-book :
Expand Down
1 change: 1 addition & 0 deletions doc/environment.lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@ dependencies:
- wcwidth==0.2.6
- widgetsnbextension==4.0.8
- zipp==3.16.2
- sphinxext-opengraph
prefix: /opt/conda/envs/jupysql-doc
7 changes: 3 additions & 4 deletions doc/integrations/chdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ JupySQL integrates with chDB so you can run SQL queries in a Jupyter notebook. J

```{code-cell} ipython3
from chdb import dbapi

conn = dbapi.connect()

%load_ext sql
Expand All @@ -39,10 +40,9 @@ conn = dbapi.connect()

### Get a sample `.parquet` file:

+++

```{code-cell} ipython3
from urllib.request import urlretrieve

_ = urlretrieve(
"https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet",
"yellow_tripdata_2021-01.parquet",
Expand All @@ -53,7 +53,6 @@ _ = urlretrieve(

+++


Query a local file

```{code-cell} ipython3
Expand All @@ -65,6 +64,7 @@ GROUP BY passenger_count
```

Run a file over HTTP

```{code-cell} ipython3
%%sql
SELECT
Expand All @@ -77,4 +77,3 @@ GROUP BY
ORDER BY c
DESC LIMIT 10
```

2 changes: 2 additions & 0 deletions doc/integrations/duckdb.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
og:image: /en/685/_static/duckdb.png
og:image:alt: 'Better SQL in Jupyter. 📊.'
jupytext:
notebook_metadata_filter: myst
text_representation:
Expand Down
35 changes: 14 additions & 21 deletions doc/user-guide/table_explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
"cell_type": "code",
"execution_count": null,
"id": "67e9f89e",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
Expand All @@ -59,11 +55,7 @@
"cell_type": "code",
"execution_count": null,
"id": "2708d4a7",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"%pip install jupysql jupysql-plugin --upgrade --quiet"
Expand All @@ -86,11 +78,7 @@
"cell_type": "code",
"execution_count": null,
"id": "dbe40317",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"%load_ext sql\n",
Expand All @@ -112,11 +100,7 @@
"cell_type": "code",
"execution_count": null,
"id": "7e6c6c7d",
"metadata": {
"vscode": {
"languageId": "python"
}
},
"metadata": {},
"outputs": [],
"source": [
"%sqlcmd explore --table \"yellow_tripdata_2021.parquet\""
Expand All @@ -137,16 +121,25 @@
"notebook_metadata_filter": "myst"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "ploomber_env",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.9.6 (default, Oct 18 2022, 12:41:40) \n[Clang 14.0.0 (clang-1400.0.29.202)]"
},
"myst": {
"html_meta": {
"description lang=en": "Templatize SQL queries in Jupyter via JupySQL",
"keywords": "jupyter, sql, jupysql, jinja",
"property=og:locale": "en_US"
}
},
"vscode": {
"interpreter": {
"hash": "70d770717fb5a42e0e8fc57cee0e68de4e4328ed30e100d18878b58ca475a80f"
}
}
},
"nbformat": 4,
Expand Down
Loading