jtsternberg / Code-Snippets-CPT

A WordPress plugin for managing and displaying code snippets
http://dsgnwrks.pro
19 stars 17 forks source link

Feature Request: Allow for multiple blocks of code in a single snippet #4

Open pmgarman opened 10 years ago

pmgarman commented 10 years ago

Similar to gists. Multiple snippets need to be tied together.

jtsternberg commented 8 years ago

That would be cool. I'll have to think about how this could work.

ramiabraham commented 8 years ago

meta boxes + post meta + repeater?

ramiabraham commented 8 years ago

Another idea: hierarchical posts, or post "groups" similar to Woo product variations.

Full disclosure: I hate myself a little bit for suggesting this.

ramiabraham commented 8 years ago

Yet another idea: arbitrary relational associations, similar to Posts to Posts.

jtsternberg commented 8 years ago

I'm a bit curious to hear how this could/would play out or be used? Would it be mainly for the code-snippet singular view (vs embedding the shortcode)?

pmgarman commented 8 years ago

Usage: Say you are writing a blog post and you want to include snippets of code, it's multiple snippets that are pieces of the larger goal here. Why go through the processes (and it's not always a fast process) of creating say 10 different posts with a few lines of code each, when you can just create one snippet, that has multiple "pieces" and then you can embed them all with [code-snippet id=123] and they show up as multiple pieces, or you can embed the piece individually in a specific spot with [code-snippet id=123 piece=321]

While @ramiabraham hates himself for it, hierarchal posts would be perfect for this. It gives the piece a unique ID for embedding. Groups the code snippets together in a solid way

jtsternberg commented 8 years ago

I'm not really feeling it. In my mind, I don't understand why you would show multiple snippets bunched together w/o text in between explaining them? Also, the process IS decently fast when you create the snippet on-the-fly with the shortcode button snippet editor. And if you want to group snippets, you can do so w/ either of the taxonomies. If anything, I could see a way of inserting multiple snippets by tax and term id, ala: [code-snippet id=123 category=laravel-think-piece]

ramiabraham commented 8 years ago

Pragmatism

That's one way to do it, and effectively does do the same thing.

Out of curiosity, would you say this is beyond the scope of the plugin? The term snippet, to me, implies a single code block. A drop-in, self-contained bit of code.

A philosophical tangent

There are obvious functional similarities between a gist and a snippet, but gists really are more analogous to standard git repositories. There's no limit to the number/type of files one can add to a gist.

However, I still totes want the gist features @pmgarman suggested.

A compromise is suggested

@jtsternberg would you be ok with some core hooks here and there if needed, in order to get an add-on working which provides "gist-like" features?

The plot revealed

Full disclosure, one of my eventual goals is to get off of gists entirely, and import them to a wp site using this plugin.


A reversal of position

Actually, circling back here again. Sorry I've been on a long journey between this sentence and the sentence directly preceding it. While I immediately went to one of the routes I noted above, this could also be done using the method you've described.

It could even be one special taxonomy, with sub cats, such as

'snippet_groups' = array(
    'group_1' => array( 1,2,3,4,5), // An array of snippet post IDs
    'group_2' => 6,7 // An array of snippet post IDs
);

(Which would then be called via something like the shortcode you noted).

jtsternberg commented 8 years ago

I'm not opposed to this concept, I'm just not feeling it. I like the proposed compromise for some hooks. Re: snippets vs gist, I'd love to eventually get off of gists as well. Or, even more ideally, keep gists in sync (and vice-versa).

rhythmpatel commented 7 years ago

I would like to display multiple snippets tied together. I would like to include HTML, CSS and JS files in single post and then provide a preview if possible and download link for entire code download.

I am searching since few days for wordpress plugin. I have tried few syntax highlighter plugins and code snippet plugins. I have not found any with exact functionalities.

I know there are gists and fiddle sites specially for that, but I am looking for something that I can host on my own site.