Luapress icon indicating copy to clipboard operation
Luapress copied to clipboard

Gallery Plugin Error: Gallery wrapped in <code> and not generating thumbnail.

Open knarxism opened this issue 5 years ago • 2 comments

Hi there, could somebody point me in the right direction? I am trying to use the default gallery plugin. What I've done so far.

  • create a page and put $! gallery !$ on that page
  • I am unsure where to place the gallery directory (images folder)? The error that I get is :
/usr/bin/lua5.1: .../rocks-5.1/luapress/4.1.2-0/plugins/gallery/init.lua:77: Gallery: not a directory: gallery/gallery
stack traceback:
	[C]: in function 'error'
	.../rocks-5.1/luapress/4.1.2-0/plugins/gallery/init.lua:77: in function 'plugin'
	/usr/local/share/lua/5.1/luapress/util.lua:169: in function '_process_plugins'
	/usr/local/share/lua/5.1/luapress/util.lua:223: in function '_process_content'
	/usr/local/share/lua/5.1/luapress/util.lua:312: in function 'load_markdowns'
	/usr/local/share/lua/5.1/luapress.lua:216: in function 'build'
	...lib/luarocks/rocks-5.1/luapress/4.1.2-0/bin/luapress:210: in function 'build'
	...lib/luarocks/rocks-5.1/luapress/4.1.2-0/bin/luapress:237: in main chunk

I've tried placing the 'gallery' folder (with images) in several different locations, but the error above keeps occurring.

  • I noticed that the plugin uses lhtml, but my template is using mustache, would this cause of the error?

  • I have the latest version of imagemagick (Version: ImageMagick 7.0.10-3 Q16 x86_64 2020-04-01)

Thanks for any insights :)

knarxism avatar Apr 01 '20 07:04 knarxism

Hi, I solved the above issue but found additional issues that are unfortunately out of my wheelhouse for now. The fix for the above error was simply creating a subdirectory in the gallery folder. The "Gallery: not a directory: gallery/gallery" solution for me was:

  1. create a folder called gallery (next to pages/posts)
  2. within the gallery folder, created a folder called "gallery" and place the images inside here (eg "gallery/gallery"
  3. create a page named gallery.md with the code "$! gallery !$"
  4. run "luapress" in the command line.

This generated the gallery (well sort of):

  • This error was generated when running the luapress code (luckily didn't have to change out my mustache template):
convert: no decode delegate for this image format `JPG' @ error/constitute.c/ReadImage/562.
convert: no images defined `public_html/gallery/gallery/thumbs/7.jpg' @ error/convert.c/ConvertImageCommand/3282.
  • once converted to lhtml, it generated the gallery code, but slapped a <code> around the result set:
&lt;a href="http://areallygreatsiteusingluapress.com/gallery/gallery/2.html"&gt;&lt;img src="http://areallygreatsiteusingluapress.com/gallery/gallery/thumbs/2.jpg" /&gt;&lt;/a&gt;
&lt;a href="http://areallygreatsiteusingluapress.com/gallery/gallery/23.html"&gt;&lt;img src="http://areallygreatsiteusingluapress.com/gallery/gallery/thumbs/23.jpg" /&gt;&lt;/a&gt;
&lt;a href="http://areallygreatsiteusingluapress.com/gallery/gallery/24.html"&gt;&lt;img src="http://areallygreatsiteusingluapress.com/gallery/gallery/thumbs/24.jpg" /&gt;&lt;/a&gt;
&lt;a href="http://areallygreatsiteusingluapress.com/gallery/gallery/3.html"&gt;&lt;img src="http://areallygreatsiteusingluapress.com/gallery/gallery/thumbs/3.jpg" /&gt;&lt;/a&gt;
&lt;/div&gt;
</code></p>
  • after I converted the code above to regular html, the thumbnail error were empty, but the regular images where fine.
  • I do have the latest version of ImageMagick and lfs installed. Not sure what I can do beyond that.

knarxism avatar Apr 02 '20 16:04 knarxism

Hey, I got this figured out - well at least to agree that I can use it!

Thumbnail Issue: Problem with imagemagick was a faulty installation, apparently its an issue from installing with source. I missed a few libraries :/ I followed this guide: https://mindaslab.github.io/2018/11/22/install-latest-version-of-imagemagick-in-ubuntu-18-04.html and changed one word (libpng12-dev to libpng-dev) at the beginning:

sudo apt-get install build-essential checkinstall libx11-dev libxext-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev libxml2-dev

That fixed the thumbnail problem above.

Code Wrap Issue: The <code> issue meant that I had to wade through lua code. I am not a lua programmer, I just like luapress :)

In my /usr/local/lib/luarocks/rocks-5.1/luapress/4.1.2-0/plugins/gallery/init.lua, i changed the line at 167 from:

-- protect from markdown
 return "<div>" .. table.concat(tbl) .. "</div>"

to

-- protect from markdown
-- return "<div>" .. table.concat(tbl) .. "</div>"
return  table.concat(tbl)

I have no idea exactly why that worked, and it does append tickmarks (```) at the beginning and at the end of the gallery.html. But that I can delete :) Not sure if there is a better solution, so I'll leave this open for now.

knarxism avatar Apr 02 '20 17:04 knarxism