Can I tell Spyder to treat files with extension .j2 as if it were .html? - jinja2

to better keep track of my files, I want to start using .j2 for jinja files instead of .html. But that promptly breaks the formatting that Spyder had been applying. Is there a way to ask Spyder to treat .j2 as if it were .html.....
I did see the "Language specification protocol" option to set up a language server but that seems overkill.

Related

Gitlist style git description

I installed gitlist on my developer server and i am trying to style the git description file of a git repository.
I tried to inject html code inside the description file but this is not recognized as html but as text.
After that, i tried to find and edit the php file of gitlist which is not allowing me to style the description file, but i didn't found something.
Is there anyone who could help me?
git-description-style http://dev.siggouroglou.gr/git-description-problem.png
From the GitList homepage:
GitList is free and open source software, written in PHP, on top of Silex and the Twig template engine.
Twig is often deployed with its escaper extension enabled, which is a relatively safe default setting. With this setting enabled, any text put into Twig templates will be escaped by default, e.g. HTML escaping will turn < into <. This extension also supports JavaScript escaping.
While this setting is enabled (and I recommend keeping it enabled), you can use the raw filter in templates to disable escaping of certain elements. This will require modifying the template code.
Assuming your description is in a variable called description, something like this in the appropriate template should do the trick:
{{ description|raw }}
Note that permitting raw output does decrease your security. Make sure you trust your users not to put anything harmful into their repository descriptions.

Treat no extension files as html?

So I'm recreating a website from web.archive.org. I've downloaded it and it has many pages. The problem is that the past site was a forum php script and now I obviously can't recreate it again. Nevertheless I will be satisfied with only being an html until I build something else.
So the problem now is that there are a lot of files generated from the query urls like this:
index.php#lang=fr
index.php#lang=fr&section=4
index.php#lang=fr&section=5
index.php#section=15&fonc=imp&lang=fr
etc...
And when I upload these files to my server the browser threats these no-extension files as text instead of an html, despite the html content inside.
Can anyone tell me why is this happening and is there an easy way to solve it?
EDIT: So apparently is the download software that I used which replaced the original urls ? with #. But if I just bulk rename all files from # to ? they still won't open. So how about the ultimate solution below, how to do that painless and fast?
Ultimately I would like to place each of the old files in one folder and rename them to html and then create htaccess rules from the original URLs to each file respectively in that folder. However doing this manually would take infinite time. So can anyone suggest a simpler solution to this?
This happens because your default content type is likely configured to be text/plain (which is the default in Apache). With HTTP, a resource type is not indicated by a file name extension, it is indicated by the Content-Type response header.
I think that you will have to set the default Content-Type header with this directive in your configuration:
DefaultType text/html
See also: http://httpd.apache.org/docs/2.2/mod/core.html#defaulttype

Prevent PHPStorm IDE From Corrupting Images

Ever since I switched from Eclipse PDT to PHPStorm, I've been having problems on my site where images won't display correctly, especially the little icons in TinyMCE. My favicon also seems to be corrupted.
I'm sure the problem is that PHPStorm is doing a newline character substitution and not respecting my image files as Binary files. When I compare an image from the server with what I have stores locally, I see that it's doing newline substitution.
Any thoughts on how to solve this?
Here's the example of what one should do in Eclipse. I think I'm looking for something similar in PHPStorm.
Settings
IDE Settings
File Types
Upper half of the dialog select Image Files. Below click on Add and type *.ico, or whetever the file extension of your files is.
Should do it
I finally got it to work!
Just before checking your project out, you need to check "change keyword substitution to" and choose "binary".

How do I "UTF-8 encode" my JavaScript files so that Google Chrome can use them in an extension?

I am writing a fairly simple extension for Chrome. The main graphical body of it (the part dealing with html, i.e. the front-end) works fine, but when I try to include a second JavaScript file that uses Jquery's $.ajax() function to return some info from another page to the front-end, Chrome throws the following error and won't let me load the extension:
Could not load extension from "Path\to\extension". Could not load file "filename.js" for content script. It isn't UTF-8 encoded.
I don't honestly know enough about UTF-8 encoding to be able to tell what would make Chrome say that about my file. I have no special characters, no accent marks or anything, which i know can screw things up. I haven't been able to find a good solution anywhere, either.
An easy way to UTF-8 encode your files, is to use an editor that allows you to choose that encoding. If you can't do that, there are (fairly standard) tools on linux/unix system to check (file) and to change (iconv, recode) the encoding. If you use Windows, such tools can be installed.
I ran into this issue even though the file was saved a UTF-8. However the code contained a U+FFFF character, which is invalid by definition. It's the same for U+FFFE.
The solution was to use "\uffff" instead of using the character directly.

HTML Include file

I have a basic web application packaged as an EAR deployed on GlassFish.
The web module has some html files.
The html files have a common footer, an html file, that I would like to extract out and make an include.
When I do, and put:
<!--#include virtual="insertthisfile.html" -->
in an html file, it does not work.
Should this work?
This is a technique called Server-Side Includes (SSI). It may not be enabled on your web host. If it is, sometimes they force a .shtml extension to be required for included files, so try renaming your file insertthisfile.shtml.
If that doesn't work, you might be able to enable SSIs in a .htaccess file (assuming your web server is Apache). You can find instructions on how to do this by googling. There's a decent set here.
If that fails, I would contact your web host and see if they have SSIs enabled.
Should this work?
Perhaps, at some special settings, with some experienced programmer, this could be useful.
In my case the include statement seems to be ignored.
I could include some text with
(embed src="include.shtml")
(/embed)
Above, I type () instead of angular brackets.
With the "embed", the setting in the header of the page does not apply to the included text; it should be repeated again, and, by default, the result is ugly.
It looks strange, as if the designers of the html did not build-in the very basic tool, the include command. For short articles, the include could save an order of magnitude in the size of files.