Exclude path in EditorConfig matching - glob

I want an .editorconfig rule that includes all *.js files, except all *.min.js files. Is this possible to achieve?
Something like this:
[*.js,!*.min.js]
max_line_length = 140

I figured out a way to solve this:
[*.js]
max_line_length = 140
[*.min.js]
max_line_length = off

Related

Changing Labels on Sphinx html page

I am using myst-parser and autoapi to generate the html page for my src folder. Everything is working fine, except I can't seem to find an option to change the labels on the left menu other than changing the html files manually.
I wonder if there is any option to write on the conf.py or index.md to set a different name for the documentation of my src folder.
As per image bellow, I just would like to change the name API Reference to something else.
This is how my conf.py file looks like
extensions = [
"myst_parser",
"autoapi.extension",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
]
autoapi_dirs = ["../src"]
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
and this is how my index.md looks like:
{include} ../README.md
{toctree}
:maxdepth: 1
:hidden:
autoapi/index

Read HTML code from file system and show in TYPO3 page

Setup
I want to transfer data from my project to a TYPO3 instance. Assume I have an HTML export that generates about 20 different HTML files inside my TYPO3 directory. These files contain data from a different system and the data updates quite frequently, so I am overwriting them regularly with the newest information.
Problem
I would like to tell TYPO3 to load the HTML contents of each file as its own page. Please note: the pages are not complete html documents (no <html> or <body> tags). Instead, I want whatever code is in those files to be displayed inside the context of a TYPO3 page. Kind of like a TYPO3 HTML PageContent, but I want the source for the HTML to be from a file.
I don't care if I have to manually set up each page, but I haven't found any way to let a TYPO3 Page or PageContent get its data from a file. Do you know of any way this would be possible?
Note: iframe isn't a solution in my case. I am using TYPO3 7.6.23
My answer is based on the following assumptions:
You have you have a "frontend provider extension" EXT:yourext; if not you can change every path like EXT:yourext/Resources/Private/Etcetera with the proper ´fileadmin/etcetera/Resources/Private/Etcetera´
You use backend_layout on database to store the backend layout and use that field to control the frontend template. I don't remember if in version 7 you can also use the filesystem using key.data=pagelayout
of course you have to adjust the IDs of the backend_layout items
the files to include will be partials, stored in the folder EXT:yorext/Resources/Private/Partials/ and will be named
MyFileToIncludeOne.html
MyFileToIncludeTwo.html
et cetera
The basic TypoScript will be something like:
page.10 = FLUIDTEMPLATE
page.10{
templateName= TEXT
templateName.stdWrap {
cObject = CASE
cObject {
key.data = levelfield:-2,backend_layout_next_level,slide
key.override.field = backend_layout
//I assume you already have some templates
1 = TEXT
1.value = Default
2 = TEXT
2.value = Home
//The layouts for the "pages with html files" begin here
10 = TEXT
10.value = MyFileOne
11 =TEXT
11.value = MyFileTwo
}
}
layoutRootPaths {
0 = EXT:yourext/Resouces/Private/Layouts/Page/
}
partialRootPaths {
0 = EXT:yourext/Resouces/Private/Partials/Page/
}
templateRootPaths {
0 = EXT:yourext/Resouces/Private/Template/Page/
}
}
So, in the previous lines,
the template MyFileOne.html will include the partial MyFileToIncludeOne.html, with just writing in it:
<f:render partial="MyFileToIncludeOne"/>
You could also use distinct paths if you want to keep the files separated:
partialRootPaths {
0 = EXT:yourext/Resouces/Private/Partials/Page/
1 = fileadmin/some/other/path/
}
I hope I have not forgotten important passages. Feel free to ask for clarifications

How to display JSON's structure in IntelliJ?

For example, for a simple file like this, it displays everything in one line:
{"315": "appear", "1529": "perVobj", "88": "JJR", "2212": "xM"}
I would like it to be displayed at multiple lines, like:
{
key:value,
key: value,
...
}
Try to use:
Ctrl+Shift+Alt+L
it would reformat your file
go to File->Settings->Code Style->JSON and set as per your needs.
Further, go to settings and create shortcut for reformat or use Ctrl+Shift+Alt+L(default) to reformat the file.
see this

Replace picture (from page header)

I have a base .docx for which I need to change the page header / footer image on a case by case basis. I read that python-docx does not yet handle headers/footers but it does handle Pictures.
What I cannot work around is how to replace them.
I found the Pictures in the documents ._package.parts objects as ImagePart, I could even try to identify the image by its partname attribute.
What I could not find in any way is how to replace the image. I tried replacing the ImagePart ._blob and ._image attributes but it makes no difference after saving.
So, what would be the "good" way to replace one Image blob with another one using python-docx? (it is the only change I need to do).
Current code is:
d = Document(docx='basefile.docx')
parts = d._package
for p in parts:
if isinstance(p, docx.parts.image.ImagePart) and p.partname.find('image1.png'):
img = p
break
img._blob = open('newfile.png', 'r').read()
d.save('newfile.docx')
Thanks,
marc
There is no requirement to use python-docx. I found another Python library for messing with docx files called "paradocx" altought it seems a bit abandoned it works for what I need.
python-docx would be preferable as the project seems more healthy so a solution based on it is still desired.
Anyway, here is the paradocx based solution:
from paradocx import Document
from paradocx.headerfooter import HeaderPart
template = 'template.docx'
newimg = open('new_file.png', 'r')
doc = Document.from_file(template)
header = doc.get_parts_by_class(HeaderPart).next()
img = header.related('http://schemas.openxmlformats.org/officeDocument/2006/relationships/image')[0]
img.data = newimg.read()
newimg.close()
doc.save('prueba.docx')

add a group of links in html

i have a word file with 100 different hyperlinks.
Eg:
http://word1.com
http://word2.com
upto http://wordn.com
I have to create a html file with these n links.
like word1 which has a hyperlink to word1.com, word2 which has a hyperlink to word2.com etc
Any easy way to do this? rather than copy pasting the link and writing the code?
You could use a JavaScript loop to do this. Such as the for loop:
for (var i=0;i<100;i++)
{
document.write('Word' + i + '');
}
like so...
I don't know if this is what you're looking for, but i hope I helped!
You can use a simple loop and create an anchor in each run. Use the .setAttribute("href", "word"+count+".com") where count keeps incrementing, using Javascript. See fiddle