r/pencilblue•
tic2000

My first impressions after using pencilblue

Before we start note that maybe some of the stuffs I want maybe exists and I'm not aware not being familiarized with either nodejs in general or pencilblue in particular. If they do exists I would really appreciate if you would point me in the right direction to look for how it works.

Also don't take my suggestions as requests that should be implemented and should be implemented NOW.

Something about me

I'm a web developer knowing all the usual stuff, php, html, jquery. I worked a lot with drupal and not just building sites by installing modules and themes and configure them properly. Which means I write code, a lot of it.

Looking to expand my skills I want to learn nodejs so I looked for a cms to start with (I don't have the skill to build my own and even if I did, I don't have the time). Looking for something I could start with I found sails with which I "played" a little and a few days I discovered pencilblue.

I installed pencilblue and I started to look for some plugins.

I found devblog theme, I installed it and... it doesn't work properly. But this way I found the first 2 things I liked to see improved.

  1. Some version dependencies check so I know to not install and old plugin (if we can call old a plugin released only 3 months ago) on pencilbue 0.3.

  2. A way to select an administrative theme. I don't want to implement a theme for frontend and being forced to build it for backend and instead use another one for that. This is made worse by the whole system on which I will talk about below.

Since I like to write code and devblog wasn't working properly I said ok, I will create a social links plugin to use in another theme. Trying to write this plugin exposed some other thinks I would like to be different.

  1. A separation between plugins and themes. Even if all are plugins, I want to be able to extend any installed theme. I don't want to install a theme because it has a "hero image" field on pages. I want to be able to "hook" (a drupal term) and add that field on any page (the field in the form and its render when a page is displayed), no matter what theme the site is using. This also means that my theme will use the angular interface without the need to duplicate those files and code in every theme on the site (this would create a lot of issue on updates or small fixes). Example: I created an issue yesterday about a page not found in the portofolio theme. If I duplicated the admin side now I'm force to fix code on all my themes on the site.

  2. A way to add css and js in a plugin that is not a theme. Copying the head.html and asking users that want to use my plugin to copy text in the theme files, and they have to do this for all 25 plugins they use on the site is not really easy maintainable.

  3. A way to extend the $scope in the angular controller. In my custom plugin I created I used the external profiles service from devblog and I wanted to add those profiles without needing to duplicate almost all the profile theme just to add profiles.

  4. Drupal has ways to add content to any page in any region. Again in my example I would like to add those social links to the header, or to the footer, or in a sidebar. In the sidebar case for example, if the theme a ^sidebar^ in a file I add to that and don't ask them to copy ^tmp_social_links^ to where they want them displayed.

I managed to create my plugin and make it work with the only requirement being to put ^tmp_social_links^ in the theme and the place you want.

You can check the plugin here https://github.com/tic2000/social-links-pencilblue and tell me if it was the right way to achieve what I want.

Posted Dec 7, 2014, 3:32 PM UTC · edited

24
devwithproblems•

So I'll speak to the ones I can answer and ask u/5trokerac3 to chime in on the others.

First off, thank you for submitting the issue yesterday and providing the feedback here today. The issues you reported should now be fixed on master.

1.1 You are correct. We have an issue for this in our backlog and it is on the roadmap. The 0.3.0 release was a major revamp of the admin UI and a few issues slipped through the cracks. In the 5 months since launch we have gotten a lot of good feedback and we are continuing to iterate and tinker with the design.

1.2 We took the approach that PencilBlue is just a set of services. The default pencilblue plugin leverages and weaves those services together to provide a base implementation of a CMS. We didn't want to create a distinction between the public facing end points and the administrative ones. At least in my mind it added complexity and tethered developers to a specific set of rules for administrative page behavior. The desired behavior you are looking can be accomplished. It is possible to have two themes installed. Have one selected as the current theme. This will prioritize it as the first place to look for routes and templates. The second installed theme will be prioritized just below it leaving the default pencilblue theme at the bottom as a last resort. This means that the active theme could provide the public facing layouts while the second theme could provide the back end. It would be up to developers whether or not they would like to segregate their theme layouts into public and administrative.

2.1 I'll speak to part of this one (I'm the back end guy). The hooks you mention would need to be built into the theme by the developers of that theme through custom directives just like the one you built except maybe in reverse. The theme developers put in directives that resolve to empty strings until a controller registers for it locally or globally with their own implementation. I think the one thing that is potentially hindering that approach is that the directive callback does not provide a reference to the template service itself which would make it hard to render a specific template.

2.2 This has been on my radar for awhile and isn't the first time it has been asked about. The approach that has been in my head has been to provide a way to add script paths or snippets through a method in the BaseController. Then the BaseController would look for a ^controller_js^ directive that would have an implementation to put specific JS in to the rendering page. Could probably have a set of directives that trigger "rendering events" or something along those lines. Thoughts?

2.4 This has also been on the radar. The thought was to have a way to register a callback that asked for scripts and css on every page render and would provide the request URL so the callback could decide if the script was necessary. Wasn't sure about performance on that so it might just be something as simple as specify script/css handler for each route.

I looked at the plugin. It looks pretty straight forward to me. I think the only part I was fuzzy on was why you removed the '$scope.'.

Lastly, we'll be sure to look at the dev blog and make sure it is working.

Thanks again for the feedback. Greatly appreciated.

2
5trokerac3•

Thanks for the heads up, tic2000. I knew I was going to forget and leave something behind with the upgrade. I've made a note on the devblog readme and added an issue.

u/devwithproblems covered most things, but here's my thoughts on 3 and 4:

3 I not 100% clear, but I think what you mean is that, since you're already using devblog, you wanted to use the external profiles service to also power your social buttons plugin. I don't think that's a likely use case, since that would tether your plugin to devblog, but I'll get at the larger picture. I think that kind of service (external_profiles) can be kicked out to being an Angular service. That way you could bring in the ^tmp_ for it and then just add it to your controller. I'll see what I can do when I update devblog to 0.3.0.

4 We've had talks about making this change, and I'm all for it. It'll probably take a little bit of time for us to totally get there though, since it's a decent sided coordination between the frontend and backend. We'll have to add the same kind of hooks that come with the AnalyticsProvider service and then pepper all themes with it.

On the admin theme, the move to Angular got us a lot closer to being able to make that happen. I think we can add a universal ^admin_css^ directive that can be changed in the site settings.

We'll talk about where all these things fit into the roadmap in our next scrum. Thanks for the feedback!

2
tic2000OP•

No. I actually copied the external profiles service to my plugin. What I meant is To not be forced to create themes just for a feature, that feature should be a distinct plugin that can be used in all themes. Think like the google analytics plugin but that doesn't render only some javascript, but also some html output. The hero image field provided by the portofolio is another example of something I should be able to do in a plugin and display on the page form regardless of the theme you are using (this is the field api in Drupal, and the hero image would be like an image field in Drupal)

Yes, I'm aware things will take time my impressions, like I said, were just some things I noticed and things I like in Drupal as a CMS.

1
tic2000OP•

Regarding the issue, I did fix it on my local, was not a big issue. I found others, but I need to create a clean install to be sure is not something I did wrong before reporting.

1.2 I don't think it adds complexity in a long term. Maybe now, when there are not many theme creators yet, since the themes need to be complete. In Drupal you can find theme oriented on the administration side and they work to improve only that section of the site. I didn't know that what you say is possible. How does it work? Can I order themes and they are used in that order? But even if it's so it's still not the best if the theme I'm using does implement some administrative stuff, like devblog-pencilblue does, but I don't like it and I like the front-end side.

2.1 Again in Drupal I don't have to put those hooks in a theme. I can, but usually they are in a module. I usually add the hooks to a theme only if it's something theme specific, but usually I do it in modules. Also in Drupal I can provide a template function or file and the theme developer can chose too over-write it in the theme or not. I don't know if in pencilblue this is possible. For example in the case of my plugin I could copy the file social_links.html in the theme plugin and on rendering that file will be used.

2.2 Something like pb.TemplateService.registerGlobalJS(path/or script, type) to add a javascript on every page. First argument being the path to file or the javascript code inside <script></script>, type to mention if it's path or code. It could have also a setting type which could add to ^angular_objects^ in the angular controller. Also there could be a pb.TemplateService.registerLocalJS which adds only to the current controller/page.

Again I'm not very familiar with nodejs yet, so I think mostly in php and drupal way.

I removed $scope because with scope it didn't work. I tried as is, I also tried to change "profile in profiles" to "profile in $scope.profiles". Neither worked. I also tried to create an angular controller, still didn't work.

Of course, again, that is probably because I'm not used to nodejs and angular yet.

1