Restrict default templates using Draw.io embed - draw.io

Is it possible to restrict the default templates used in draw.io? I can restrict the custom libraries accessible by passing in an array at the start, but there appears to be no such parameters that limit the initial templates.
I've went through the documentation but still cannot find the option to modify. It's not a deal-breaker but I'd love to be able to reduce these templates dramatically.

Unfortunately, this is not possible.
BR,

Related

Django -- hide links from certain users

Is it possible, on a Django webapp, to hide certain links from those users who do not have the permission to click the link?
I bet there is a per-link way to check if the user has persmission to click the link, and then show the link (or not) based on that test. However, when there are a lot links spread across a whole bunch of web pages, that can be ridiculously tedious. Are there any ways to achieve this across the whole website with a setting or something?
write a template tag similar to spaceless that goes over its contents and removes all links that are not accessible. this would save you from having to touch each link manually.
It might be possible to write a custom template tag that would accept a link url, reverse it, introspect what permissions were required for the target view, and then conditionally display it.
You'd still have to touch every link in every template that you wanted to make fancy like that, and it would probably be an ugly beast. All in all, it's probably easier if you come up with a more centralized way to control access.

Using the Coldbox framework, is there a way to intercept a renderView call and execute a different template?

I am trying to learn Coldbox to perhaps replace the current framework I am using. One of the features that I currently use is the ability to override any of the template inclusions by convention.
Essentially, lets say I have a view, "views/home.cfm"
<h1>I am the default theme</h1>
and that is all well and good. But lets say that I have a different view, "themes/[theme-name]/views/home.cfm"
<h1>I am the user chosen theme</h1>
that I want to include conditionally (say there is a cookie to determine what theme is in use). Also, if the file does not exist, the default/fallback view should be rendered.
Is there any way of doing this overriding the system functions?
I looked at interceptors, and the preViewRender and postViewRender interceptors seem like the place to do something like this, but there doesn't seem to be any way of manipulating the actual workflow. If seems to be mainly pre/post processing of the content. For instance, there doesn't seem to be a way to "return false" to tell the renderView method to not actually render the view. Or any way to affect the location in which the view is to be found.
Any ideas?
Tyler,
The ColdBox Framework is quite flexible. It is possible to do what you desire but I don't think modifying renderView() is the best way to resolve this--although, you most definitely can.
I would encourage you to create a User Defined Function in the /includes/helpers/ApplicationHelper.cfm file that contains the logic you require. The functions that are added to this helper file are accessible from anywhere in the framework. This would allow you to create a function called "renderSkin()" that contains the logic you need. RenderSkin() would ultimitly call "renderView()" when you finally figured out which template you wanted to render for that user.
Respectfully,
Aaron Greenlee
I would suggest you go with the interceptor route, but change the layout instead of the view.
From the postEvent interceptor you can get the processedEvent key from the interceptData to change the layout.
Otherwise you could just make the check part of the layout page. The layout can the be a switch statement (or a more OO approach) $including the themed layout files as needed. This has the advantage of giving you a chance to emit custom interception points and having common functionality (css, js)

Django: what is the most appropriate way to provide administrators with the ability to change small snippets of text

Using Django, what is the most appropriate way to provide administrators with the ability to change small snippets of text, for example in one of my sites there is a small piece of text on the front page I would like the administrator to be able to easily change in the backend, however I do not want to create a whole new app or model because then they would be able to create more than one area of text in this way, but I only want it to show up in one place on the homepage.
Any advice?
This might be a bit more than you're looking for, but django-chunks lets you embed snippets of text into your templates and allow administrators to edit them. Because the only way to put a chunk into a template is by embedding it yourself, you don't have to worry about someone creating additional chunks - they just won't show up anywhere on the site.
Create a new setting in the settings file (or if you're using something like Djblets, in the appropriate model [or if you're using something else, wherever it expects settings to be]) for it, and then use it in the template after passing the appropriate context.

How to ensure that a javascript file is included only once in Django

I have a few child templates which have extraheads which include the jquery script. Sometimes they are used together. How can I have the jquery javascript file loaded only once? If it were convenient to set template variables, I could set and check one before including the line.
My advice: Just include jQuery on your base's <head> and call it a day. Saves you from having to worry if a child template uses jQuery or not and it is just a 19kb download on the first page load and that's it. If you use Google's API cloud, it may not even be any as the user might have it cached from another site.
This may not work for you, but I advice you to consider it if possible.
My usual approach to this problem is to either wrap all of my child templates in one template that takes care of my includes (JS and CSS). I then make sure my caching is set properly, so that these scripts are only downloaded once per user. In other words, I force the download of all my external scripts on the first view, then rely on caching to not redownload the JS each time.
Combining all of your JS into one file will also improve download time due to the reduction in requests that will be generated.
Another thing to note is that you mentioned putting the JS in heads. While most people do this, placing JS in the head can make your pages appear to load slower. JS files are not downloaded in parallel, so they block all other downloads. Google and Yahoo recommend placing JS at the bottom of your page where possible to improve the user experience.
See the Yahoo YSlow tool and the Google PageSpeed tool for this.
I'd mostly bite the bullet and load jQuery with every template. But if you really really really have to have this feature, then I'd recommend a custom template tag. Check out the docs, especially the part about setting a variable in the context.
You could define separate blocks for your script and for other extraheads in base template.
In base template leave block for your script blank. Fill it with link to a file when needed in templates which are extending base.
You could pass all required files as a context variable and then write a template tag that removed duplicates and loaded what was left.
You could control load order this way also.

How can I pass a standard, static variable from all views in Django?

I'm working on a blog application, and I want to have a sidebar that includes a list of all the months the blog has been in existence, to provide links to archives pages. Moreover, I'd like to make this automatically update when the month changes, rather than hardcoding it in the template. Of course, as far as I can tell, this means that I'll have to calculate the list of months in every view, and pass it into every template from every view.
I'd like to avoid this, if possible. Is there a way to calculate the list once and automatically apply it to every template, without having to explicitly pass it into the template from every view?
There are a few possible solutions to your problem.
If you really want to have this on every page on your site a context processor is probably your best choice. Context processors are basic way to inject data into all template contexts. Be aware however that the context processor will be called on every request.
An alternative solution would be to create a custom template tag and use it on a shared base template for all of the pages you wish to have your sidebar. Template tags are a bit more complex to create but they are more flexible.
With either solution you should also look at Django's cache framework. The cache framework makes it pretty easy to temporarily store your calculated values for a while to save some work on each request.
You want a template context processor
Django - having middleware communicate with views/templates
http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#id1
Django's template inheritance should cover this. You could create a base template that handles your sidebar functionality. Your other views extend this template.
Template Inheritance:
http://www.djangobook.com/en/1.0/chapter04/#s-template-inheritance
A combination of custom template tags as mentioned previously and template fragment caching should do the trick.