How can I implement relative urls (with #) in crafter 3? - crafter-cms

I am using viewerjs library in crafter 3
The thing is the library uses a relative url in order to work just like this:
<a href="http://example.org/ViewerJS/#../path/to/filename.ext">
the problem is when I do the same in crafter I get this error:
Caused by: org.craftercms.core.exception.StoreException: Unable to find content: ../data/repos/sites/viewerv2/sandbox/static-assets/viewerJS is not a file
Is there any way to fix that?

Fixed:
/viewerJS/index.html#../path/to/the/file.ext
instead of just write #.. we need to add the index.html as well, and the path to the file

Related

URL Binding issue Vue/webpack

I'm having a peculiar problem when I'm trying to bind an img-tag to a dynamic url.
After finding some similar solutions I found the way to go was by binding the src attribute like this
:src="require(....)"
The problem is however that it only works in the specific format
:src="require('#assets/vendor-'+name+'.svg')"
I'd like to use format src:="require(path)" but I can't seem to get this solution to work.
After some reading some suggestions would point to Webpack causing the issue but currently my knowledge is very limited.
EDIT 1:
Currently I have to extract the name from the JSON-file and add it to that path rather than just using the path found in the JSON-file.
:src="require('#/assets/vendor-' + this.$store.state.vendors[this.cardInfo.vendor].name + '.svg')"
I'd like to make this work
:src="require(this.$store.state.vendors[this.cardInfo.vendor].baseUrl)"

Change phpbb3.1 style to twig syntax

Recording to this, version 3.1 of phpBB should parse their old syntax to twig style now. I would like to use the parsed twig files to create a new style. I guess they can be found in the cache folder, but thats not very comfortable to reuse.
So Iam looking for the method that parses the old style to the knew one and to use it on the original files. I couldn't find it yet by just crawling through the sourcecode.
I found it myself. Its in the phpBB3/phpbb/template/twig/lexer.php file.
To use the class standalone, just remove
extends \Twig_Lexer
and replace
return parent::tokenize($code, $filename);
by
return $code;
Then you can run
$lexer = new lexer();
echo $lexer->tokenize($originalTemplateCode);
//returns template-code in twig-style syntax
Of course, thats a dirty hacked solution, but as long you only need it once to change the basic style for using it, its ok to do so

Symfony3 customizing error pages (404, 403...)

I don't know what is wrong but I couldn't override the error pages as describe in the documentation by simply create the related file at app/Resources/TwigBundle/views/Exception/error.404.html.twig or app/Resources/TwigBundle/views/Exception/error.403.html.twig and so on...
Notice that I also clean the cache as well before check it: bin/console cache:clear --env=prod. I'm using Symfony 3.0.6
the twig file name should be:
error404.html.twig
not:
error.404.html.twig
Let me know if you still have problems. This should work, because I've used it.

SublimeText3 + pandown + pandoc: includes_paths not working

I'm using ST3+pandown+pandoc to convert markdown to PDF. I want to use pandown's includes_paths setting to avoid typing the path to my image directory every time. I haven't been able to get it to work, however. Here's a MWE:
I have a directory structure as follows:
text.markdown
test/img.pdf
In text.markdown, I have:
![](img.pdf)
I've got set includes_paths as follows in Pandown.sublime-settings:
"includes_paths":
[
"test/"
],
But, no dice. I've also tried with an absolute path, ./test, and test. Any ideas?
I think Pandown's includes_paths only applies to Pandoc's --include-in-header, --include-before-body and --include-after-body options, not image locations etc.
From Pandown.sublime-settings about includes_paths:
Pandoc apparently doesn't search for values for its --include
arguments anywhere but the working directory, which makes
working from a standard stylesheet or standard script
sort of tedious.
A workaround, using the graphicx package loaded in the YAML header and \graphicspath:
---
header-includes:
- \usepackage{graphicx}
---
\graphicspath{{test/}}
![](img.pdf)
Pandoc will say that it can't find img.pdf, but the image will be present in the final pdf.

Using a Twig Extension

I am trying to use teh Twig i18n Extension.
As far as I can tell the file I need is here:
https://github.com/fabpot/Twig-extensions/blob/master/lib/Twig/Extensions/Extension/I18n.php
Now I am not quite sure where to save this file
I have Twig in a folder called includes/lib (/includes/lib/Twig). I see a folder Extension under Twig. Do I save it here?
After I save it, do I need to do a "require_once" to the file or will Twig_Autoloader do the job for me?
I am not using Symfony2
Thanks
Craig
Here is the complete answer that worked for me:
Copy the file in Twig-Verzeichnis (extract i18n.zip in Twig).
For the I18n extension it would be Twig/Extensions/Extension/I18n.php
Eventually add other files requred by I18n. You will see what these are by the error messages that come. I had to add "Twig/Extensions/Node/Trans.php" and "Twig/Extensions/TokenParser/Trans.php".
In your config file add the following:
// Set language to German
putenv('LC_ALL=de_DE');
setlocale(LC_ALL, 'de_DE');
// Specify location of translation tables
bindtextdomain("project_de_DE", "./locale");
// Choose domain
textdomain("projectl_de_DE");
Register the Twig Extension
$twig->addExtension(new Twig_Extensions_Extension_I18n());
Create the directory locale/de_DE/LC_MESSAGES
Create the PO file (the easisest is to have a sample file to start from)
Open the file in a normal text editor (be sure to use utf-8 encoding) and start translating
Open the PO-Datei with PoEdit (www.poedit.net/)
Save to locale/de_DE/LC_MESSAGES (a MO-Datei will be created).
Add the translation to the appropriate places in the Twig-Template with
{% trans 'Text in the original language' %}`
You need to register this extension with Twig:
$twig->addExtension(new Twig_Extensions_Extension_I18n());
If your installation is configured correctly, the autoloader should do the job of including the file. If not, you could include the file manually or make the installation with composer.
It seems the "proper" way to install these extensions without Composer is as follows:
Download a release from https://github.com/fabpot/Twig-extensions/releases
Copy the contents of the lib/ directory somewhere to your project
include the file .../Twig/Extensions/Autoloader.php
Register autoloader: Twig_Extensions_Autoloader::register();
Continue as explained in the doc: http://twig.sensiolabs.org/doc/extensions/i18n.html

Resources