diff --git a/CHANGES.rst b/CHANGES.rst index f7f83a9..318e38a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changes ####### +2.1.0 (*2023-08-17*) +~~~~~~~~~~~~~~~~~~~~ + +- Use node image type to be compatible with ablog's excerpts + 2.0.0 (*2023-08-11*) ~~~~~~~~~~~~~~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index 61424cd..bbf5b7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "sphinx_galleria" -version = "2.0.0" +version = "2.1.0" requires-python = ">=3.8" dependencies = [ "Sphinx>=7.0.0", diff --git a/sphinx_galleria/collector.py b/sphinx_galleria/collector.py index e32a61b..04f2870 100644 --- a/sphinx_galleria/collector.py +++ b/sphinx_galleria/collector.py @@ -78,7 +78,7 @@ class GalleriaCollector(EnvironmentCollector): del imageglob['thumbsize'] glob_path = os.path.join( os.path.dirname(node.source), - imageglob['path'] + imageglob['uri'] ) for image_path in glob.glob(glob_path): @@ -97,7 +97,7 @@ class GalleriaCollector(EnvironmentCollector): jsonimage['thumb'] = os.path.relpath( thumb_path_cropped, app.env.srcdir) - jsonimage['path'] = os.path.relpath( + jsonimage['uri'] = os.path.relpath( image_path, app.env.srcdir ) diff --git a/sphinx_galleria/directive.py b/sphinx_galleria/directive.py index 6676889..1280fdb 100644 --- a/sphinx_galleria/directive.py +++ b/sphinx_galleria/directive.py @@ -77,16 +77,16 @@ def html_visit_galleria(self: HTMLTranslator, node: galleria) -> None: if len(node['images']) > 0: self.body.append("
") self.body.append("%s" % ( - node['images'][0]['path'], + node['images'][0]['uri'], node['images'][0]['title'], node['images'][0]['alt'] )) self.body.append('
') for img in node['images']: - img['path'] = relative_uri( + img['uri'] = relative_uri( self.builder.get_target_uri(self.builder.current_docname), - img['path'] + img['uri'] ) img['thumb'] = relative_uri( self.builder.get_target_uri(self.builder.current_docname), @@ -129,7 +129,7 @@ def text_visit_galleria(self: TextTranslator, node: galleria) -> None: def gemini_visit_galleria(self, node: galleria) -> None: for image in node['images']: - self.body += '=> %s %s' % (image['path'], image['alt']) + self.body += '=> %s %s' % (image['uri'], image['alt']) raise nodes.SkipNode @@ -215,9 +215,15 @@ class GalleriaDirective(Directive): image["thumbsize"] = self.options.get('thumbsize') or '100x100' image["hide_alt"] = 'hide_alt' in self.options image["hide_title"] = 'hide_title' in self.options - image["path"] = path + image['uri'] = path node['images'].append(image) + image_node = nodes.image() + image_node['alt'] = image['alt'] + image_node['uri'] = image['uri'] + image_node.parent = node + node.children.append(image_node) + if created: return [node] return [] diff --git a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs index b18b59e..18e5ec4 100644 --- a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs +++ b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs @@ -283,7 +283,7 @@ export class SphinxGalleria { var image_element = document.createElement('li'); var image_button = document.createElement('input'); image_button.setAttribute('type', 'radio'); - image_button.setAttribute('value', image_data.path); + image_button.setAttribute('value', image_data.uri); image_button.setAttribute('name', self.target); image_button.setAttribute('data-index', idx); image_button.setAttribute('id', self.target+'-'+idx);