asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
105 stars 101 forks source link

Create a meme generator extension #8

Open mojavelinux opened 10 years ago

mojavelinux commented 10 years ago

53297362

Let's ruin the internet. R U with me?

aalmiray commented 10 years ago

checks date. Nope, it's not April 1st. So I guess this is really happening. :+1:

Proposed syntax:

meme::<meme_id>[top="memes in asciidoc", bottom="o rly?", lang="en"]

The catch will be to properly identify the meme_id used by memegenerator, as we don't want to build a list of aliases, do we? (how can we keep up with new memes popping up?)

jbaruch commented 10 years ago

I think url of image will be more flexible than meme_id. Can be usable outside of scope of memegenerator and won't have the watermark.

aalmiray commented 10 years ago

it depends on the meme generator service to be used by the meme macro. Notice the lang option? it may not be supported by others. Also memegenerator.net accepts uploading to img.ur and authenticated users. I guess it makes sense to come up with a list of options this extension must support.

mojavelinux commented 10 years ago

:wink:

@aalmiray I think you definitely have the right idea. The meme_id could be an id or a URL, and the extension can be smart about what to do. We could also default to English if language isn't specified.

Remember, we can use positional attributes to make it shorter...and quotes are only required if there's a comma in the content.

meme::Y_U_NO[Write memes?]

If we get the meme_generator gem working again, it queries for a list of meme characters, so you can always pull it from the commandline. Actually, the list still works, the generator just fails.

jbaruch commented 10 years ago

Wait a second, why you need a service at all? All you need is image as a bg to write on top of it in caps impact bold font. Can't we do it without a service?

aalmiray commented 10 years ago

@jbaruch: Ugh, no. I don't want to deal with an image manipulation library that requires a local gem to work.

@mojavelinux: a downside of using a service is recreating the same image with every build, unless some kind of caching/verification is put in place. Agreed on making English the default lang; I was just stating some of the options that may be used ;-)

mojavelinux commented 10 years ago

Absolutely we can. mini_magick (works on Ruby and JRuby). In fact, I just implemented something similar for doing the covers for NFJS, the Magazine. See, real work enables play!

https://github.com/opendevise/editions/blob/master/lib/editions/cover_annotator.rb

aalmiray commented 10 years ago

@jbaruch: on the plus side you can use any image you'd like, not just those available in the memegenerator service. I guess a local generator also solves the problem of duplicate images being uploaded.

The other downside I see is grabbing the images in the first place. I guess we can't win them all :P

mojavelinux commented 10 years ago

Good news. The caching stuff is already implemented as part of Asciidoctor Diagram. That's why I think we could actually build on Asciidoctor Diagram APIs to make this extension...at least handle all the outer parts of managing the image and cache.

See https://github.com/asciidoctor/asciidoctor-diagram/blob/master/lib/asciidoctor-diagram/util/diagram.rb#L96

mojavelinux commented 10 years ago

I'd start with using the service, then add the local build as the code matures. hahaha, meme code maturing...isn't that an oxymoron? Or just a moron?

aalmiray commented 10 years ago

methinks we need a new meme for this case :smile_cat:

pepijnve commented 10 years ago

It's a shame ruby doesn't have a graphics api in the std lib. If depending on Java is ok, this kind of code is pretty trivial to write with Graphics2d. The only downside is that you're going to have to provide a URL to the base image; beyond that the syntax can be the same as what was proposed above.

The memegenerator.net service doesn't seem to be very reliable. I was browsing it a bit and I get lots of timeout errors.

mojavelinux commented 8 years ago

This is now implemented in Asciidoctor Diagram. Shall we close this issue?

See https://github.com/asciidoctor/asciidoctor-diagram#the-meme-extension

meme::yunoguy.jpg[Doc writers,Y U NO \\ AsciiDoc]
pepijnve commented 8 years ago

The diagram implementaties does the image processing locally though. I had a look at using existing generator services but I couldn't figure out how to make those work without either having to do a search query (and possibly using the wrong image) or specifying the base image via its numeric id. Both seemed rather impractical.

mojavelinux commented 8 years ago

specifying the base image via its numeric id

That's how the YouTube and Vimeo support work, so it's certainly not a foreign concept in the ecosystem.