Use image node
This commit is contained in:
parent
8ac04991ac
commit
15710ef3c2
5 changed files with 20 additions and 9 deletions
|
@ -1,6 +1,11 @@
|
||||||
Changes
|
Changes
|
||||||
#######
|
#######
|
||||||
|
|
||||||
|
2.1.0 (*2023-08-17*)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
- Use node image type to be compatible with ablog's excerpts
|
||||||
|
|
||||||
2.0.0 (*2023-08-11*)
|
2.0.0 (*2023-08-11*)
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "sphinx_galleria"
|
name = "sphinx_galleria"
|
||||||
version = "2.0.0"
|
version = "2.1.0"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Sphinx>=7.0.0",
|
"Sphinx>=7.0.0",
|
||||||
|
|
|
@ -78,7 +78,7 @@ class GalleriaCollector(EnvironmentCollector):
|
||||||
del imageglob['thumbsize']
|
del imageglob['thumbsize']
|
||||||
glob_path = os.path.join(
|
glob_path = os.path.join(
|
||||||
os.path.dirname(node.source),
|
os.path.dirname(node.source),
|
||||||
imageglob['path']
|
imageglob['uri']
|
||||||
)
|
)
|
||||||
|
|
||||||
for image_path in glob.glob(glob_path):
|
for image_path in glob.glob(glob_path):
|
||||||
|
@ -97,7 +97,7 @@ class GalleriaCollector(EnvironmentCollector):
|
||||||
jsonimage['thumb'] = os.path.relpath(
|
jsonimage['thumb'] = os.path.relpath(
|
||||||
thumb_path_cropped,
|
thumb_path_cropped,
|
||||||
app.env.srcdir)
|
app.env.srcdir)
|
||||||
jsonimage['path'] = os.path.relpath(
|
jsonimage['uri'] = os.path.relpath(
|
||||||
image_path,
|
image_path,
|
||||||
app.env.srcdir
|
app.env.srcdir
|
||||||
)
|
)
|
||||||
|
|
|
@ -77,16 +77,16 @@ def html_visit_galleria(self: HTMLTranslator, node: galleria) -> None:
|
||||||
if len(node['images']) > 0:
|
if len(node['images']) > 0:
|
||||||
self.body.append("<figure><div class='row'>")
|
self.body.append("<figure><div class='row'>")
|
||||||
self.body.append("<img src='%s' title='%s' alt='%s'>" % (
|
self.body.append("<img src='%s' title='%s' alt='%s'>" % (
|
||||||
node['images'][0]['path'],
|
node['images'][0]['uri'],
|
||||||
node['images'][0]['title'],
|
node['images'][0]['title'],
|
||||||
node['images'][0]['alt']
|
node['images'][0]['alt']
|
||||||
))
|
))
|
||||||
self.body.append('</div></figure>')
|
self.body.append('</div></figure>')
|
||||||
|
|
||||||
for img in node['images']:
|
for img in node['images']:
|
||||||
img['path'] = relative_uri(
|
img['uri'] = relative_uri(
|
||||||
self.builder.get_target_uri(self.builder.current_docname),
|
self.builder.get_target_uri(self.builder.current_docname),
|
||||||
img['path']
|
img['uri']
|
||||||
)
|
)
|
||||||
img['thumb'] = relative_uri(
|
img['thumb'] = relative_uri(
|
||||||
self.builder.get_target_uri(self.builder.current_docname),
|
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:
|
def gemini_visit_galleria(self, node: galleria) -> None:
|
||||||
for image in node['images']:
|
for image in node['images']:
|
||||||
self.body += '=> %s %s' % (image['path'], image['alt'])
|
self.body += '=> %s %s' % (image['uri'], image['alt'])
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,9 +215,15 @@ class GalleriaDirective(Directive):
|
||||||
image["thumbsize"] = self.options.get('thumbsize') or '100x100'
|
image["thumbsize"] = self.options.get('thumbsize') or '100x100'
|
||||||
image["hide_alt"] = 'hide_alt' in self.options
|
image["hide_alt"] = 'hide_alt' in self.options
|
||||||
image["hide_title"] = 'hide_title' in self.options
|
image["hide_title"] = 'hide_title' in self.options
|
||||||
image["path"] = path
|
image['uri'] = path
|
||||||
node['images'].append(image)
|
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:
|
if created:
|
||||||
return [node]
|
return [node]
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -283,7 +283,7 @@ export class SphinxGalleria {
|
||||||
var image_element = document.createElement('li');
|
var image_element = document.createElement('li');
|
||||||
var image_button = document.createElement('input');
|
var image_button = document.createElement('input');
|
||||||
image_button.setAttribute('type', 'radio');
|
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('name', self.target);
|
||||||
image_button.setAttribute('data-index', idx);
|
image_button.setAttribute('data-index', idx);
|
||||||
image_button.setAttribute('id', self.target+'-'+idx);
|
image_button.setAttribute('id', self.target+'-'+idx);
|
||||||
|
|
Loading…
Reference in a new issue