In CKAN, is it possible to override templates of customized extensions? - jinja2

I created a CKAN extension for blog. The blog extension overrides ckan core template files and working fine.
Then I created another extension called ui, to create a new template for ckan. In this new extension can I override my blog extension's template files?
For example: if I have 'blog/templates/blog_post.htm' in blog extension, can I override it in ui extension by '/ui/templates/blog_post.htm'
This way I can keep my extension working with ckan template and it working with my new templates.

Yes, you can override template from other extensions. You just need to be careful with the order in which you load the plugins in your ini file (the one overriding the templates should be loaded first).

Related

Writing a plugin file in ClojureScript for use in CKEditor

I currently have a project that is using ClojureScript, shadow-cljs, re-frame, and CKEditor.
I am trying to figure out how to write a custom plugin for CKEditor usoing CLJS instead of JS.
CKEditor uses the following to load external custom plugins
// Loads a plugin from '/myplugins/sample/my_plugin.js'.
CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' );
Is there a way to write my_plugin.js in CLJS in my current project?
I think your question is: I have a CLJS project that uses shadow-cljs and happens to use CKEditor as a library. I also want to create a plugin for CKEditor within the same project.
If that's the case, I think what you need is just create a new build for the plugin code in the :builds section of your shadow-cljs.edn file and configure it properly (eg. source files, etc.). See the Build Configuration section of the shadow-cljs User's Guide for details.
Once you build your plugin, it will put the output JS file in some location. Probably you need to copy this plugin JS file to a location in the "parent" project before building the main project.

Where is the site.css file located for Identity?

I have an asp.net core 2.1 MVC application. I have ran the Scaffold Identity which has generated all the HTML and models used. I can't however find the css file that identity is using for its layouts?
In chrome developer tools it tells me site.css is being loaded from /Identity/css/site.css and bootstrap is being loaded from /Identity/lib/bootstrap/dist/css/bootstrap.css. These files don't seem to exist anywhere in my project. Am I missing something?
It's not using the site.css file that's located in wwwroot/css.
The Identity default UI is a Razor Class Library. The static resources are being embedded and loaded from the library. Specifically, the Static Files middleware is loading up the embedded resources as if they were on the filesystem, using a ManifestEmbeddedFileProvider.
Long and short, you can override those by simply creating files in the same location in your project. Then, your project's versions will take over. Unfortunately, the scaffold doesn't provide a way to scaffold static resources as well. However, you can simply view the source in your browser and then copy that into your project's version of the file.
You can also view the source of the RCL here. That way you can reference whatever code you need, without even needing the scaffold. Anything you add to your own project overrides what's coming from the RCL.

How to embed Go HTML templates into code?

I have a set of templates as files, like base.html, login.html, profile.html, header.html and so on. They are structured in folders.
It's fine to have them as separate files during development but when I deploy the app, I'd like to have them all embedded as strings or parsed and compiled templates ready to use from the code as usual.
How should I better make these templates as Go code? So that I don't have to have a templates folder in production, but everything in the single executable file?
With Go 1.16 there would be official "embed" package and the following would be possible (is possible if you read this after February 2021):
//go:embed "mytemplate.tmpl"
var myTemplate string
This code embeds mytemplate.html at compile time and it becomes available as a string (or as []byte or as a FileSystem, if you wish). No 3rd-party tools or libraries needed.
The most simple solution is to embed templates in string literal inside Go source code.
There is a tool that can help, see go-bindata.
I used go generate in some of previous projects for this type of operation, see blog post on go generate command for introduction.
As of the Go 1.16 release, there is the //go:embed comment directive.
This allows you to directly embed files in your binary.
Link for draft design of the go:embed comment directive
Link for the Github issue for go embed with some updates
In addition to go-bindata which was already mentioned, there is go-bindata-assetfs which you can use to serve static files from a webserver. It's good for Javascript, CSS, etc.

Template tags in CKAN 2.4

I am currently writing a CKAN extension. Now I need some custom tags in my HTML templates as they are present in Django. The CKAN documentation is not exactly verbose on this topic. Does anybody know whether I can add custom tags in CKAN?
The code that loads jinja and adds ckan's own custom tags is here:
https://github.com/ckan/ckan/blob/0b7aa77e5e38d1376050b638d19a88da67346ea6/ckan/config/environment.py#L216-L227
Check out the jinja docs to see if you can add to it once its created, which you could do from an extension. Otherwise, create a new plugin point and submit it as a PR.

Can you bundle live templates into a plugin/package in PHPStorm?

I have a selection of live templates / snippets specific to a particular framework that I would like to distribute as a plugin/package. Is it possible to do this for PHPStorm/WebStorm?
I have managed to do this for the Sublime Text 2/3 editor very easily and my package is now accessible via the package manager. In short I'm wanting to do the same for PHPStorm, allowing people to download my live templates as a plugin from the plugin repository.
I think you can use answer from this question How can I create custom Live Templates with an Intellij plugin.
You need to create DefaultLiveTemplateProvider and register it in plugin.xml