Plugin approach?

Post Reply
mjxl
Posts: 9
Joined: Thu Jan 30, 2020 4:57 am

Plugin approach?

Post by mjxl »

Hey people!

I figured it was about time to put something on my domain instead of a blank HTML file, so installed WonderCMS and absolutely love how easy it is.
(after cpanel install i realised checking this project out LOOOONG time ago lol!)

I was wondering though, is there any right/wrong approach of doing a plugin?
I looked at a the ones out on github, and came up with this example:

Code: Select all

$('#content').one('click', function() {
  (a = $(this)), (title = a.attr('id'));
  setTimeout(() => {
    let UpDaTe = a.children(':first').attr('onblur');
    console.log(UpDaTe);
    a.children(':first').removeAttr('onblur');
    let simplemde = new SimpleMDE({
      element: $('textarea')[0],
      toolbar: [
        {
          name: 'save', // saving simplemde back to wondercms
          action: function(editor) {
            fieldSave(a.attr('id'), editor.value(), a.data('target'), a.data('menu'), a.data('visibility'));
          },
          className: 'fa fa-save',
          title: 'Save!',
        },
      ],
    });
  }, 100);
});
Am i doing things right or is it super cheaty? I haven't a clue LOL

It works in any case:
Image

wiz
Admin
Posts: 423
Joined: Sat Oct 30, 2010 12:23 am

Re: Plugin approach?

Post by wiz »

Hey mjxl, welcome to the community.

Glad you're loving it, any feedback is always appreciated.

Your plugin looks pretty good. Not cheaty from my perspective, but my code can sometimes be cheaty (so who am I to judge code?)
Mind sharing the structure a bit more (like, did you create a plugin folder, one file, how is everything included)?

mjxl
Posts: 9
Joined: Thu Jan 30, 2020 4:57 am

Re: Plugin approach?

Post by mjxl »

The rest is set up just like the other plugs!

wonder-markdown.php
js/load.js (the stuff in first post)
js/simple-mde.js
css/simple-mde.css

I still need to figure out if i can render the content to the actual page via simple-mde, or if i need to include markdown-it/snarkdown js library. :P

mjxl
Posts: 9
Joined: Thu Jan 30, 2020 4:57 am

Re: Plugin approach?

Post by mjxl »

I think it's ready to post online tbh ! (Together with another editor (very excited about this one!!))

Should i just upload them on GitHub or is it maybe a good idea to post them here for review?

wiz
Admin
Posts: 423
Joined: Sat Oct 30, 2010 12:23 am

Re: Plugin approach?

Post by wiz »

Good work!
You can upload it to GitHub and we'll review and test it. :)

mjxl
Posts: 9
Joined: Thu Jan 30, 2020 4:57 am

Re: Plugin approach?

Post by mjxl »

wiz wrote:
Wed Feb 05, 2020 8:39 am
Good work!
You can upload it to GitHub and we'll review and test it. :)
Did i do it right? :lol:
viewtopic.php?f=23&t=1271

wiz
Admin
Posts: 423
Joined: Sat Oct 30, 2010 12:23 am

Re: Plugin approach?

Post by wiz »

Replying there. :)

Post Reply