Is my file path for including an ejs partial correct? - filepath

My ejs header partial is in a directory below my index.ejs so the file structure goes:
app/views/index.ejs
app/views/partials/header.ejs
When I deploy locally with 'heroku local web' my static site works fine and I can navigate it. But when I try to deploy it online with 'heroku open' it errors:
ENOENT: no such file or directory, open
'/app/views/partials/header.ejs'.
<!-- header -->
<% include partials/header %>
What can I do?
Link to Github

Your partial folder starts with a uppercase 'P'
https://github.com/tomtam6/tom-tam/tree/master/views/Partials
and you have used lowercase 'p' in your code https://github.com/tomtam6/tom-tam/blob/master/views/index.ejs#L2

Related

Can js file be compiled in a different folder from the source folder?

I'm building an Obsidian plugin, and it uses esbuild to bundle ts file to js file. The ts file is located at D:\foo1\foo2\..., and I want the js file to be at D:\bar1\bar2\.... The reason for this is because I want the source folder is in a different folder than the plugin folder, so that when syncing it to mobile I don't have to exclude the source files.
I was suggested to edit the esbuild.config.mjs file, and I find in the documentation that beside the outfile config there are also outdir, outbase. However, these are the results when I'm using them:
outdir
outdir: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker'
error: Failed to create output directory: mkdir D:\GitHub\Obsidian\dotmaker\D:Quả CầuB Nội dungKnowledge graphsCây vấn đề.obsidianpluginsdotmaker: The directory name is invalid.
outbase
outbase: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker',
It prints the js content in the terminal, but the real file isn't changed.
It seems that I can only create the js file inside the source folder. Is that possible?
You didn't correctly format the content of the outdir setting. When using backslashes \ as path separator on windows, you have to escape them. Ie use
outdir: 'D:\\Quả Cầu\\B Nội dung\\Knowledge graphs\\Cây vấn đề\\.obsidian\\plugins\\dotmaker'

how to use php scripts in datalife engine template files?

I want to read and display something from the database on the DataLife Engine homepage with php script.
Something like the last few news shows.
But when I call the file containing the PHP script inside the DataLife Engine template files (with the .tpl extension) (like this:{include file="test.tpl"}), this script don't work and don't show anything.
when I call the php file like this ({include file="test.php"}) in .tpl files, Data-Life-Engine show me an error with this description: Include files from root directory is denied.
Please help me to use a PHP script in the DataLife-Engine template file.
Thanks
first you must put your PHP file in the path "engine/modules".
Then call it in your template file as follows:
{include file="engine/modules/TEST.php"}

Wagtail new installation : CSS not working

I tried the official installation guide for installing wagtail locally :
first by creating a website
second by integrating wagtail into a new website
Each time it seemed to work fine functionally but all the CSS was broken (see pic down)
I tried to do "manage.py collectstatic", it told me that 2/3 hundred files have been copied, I emptied the cache of my browser, loaded the page again, no change.
In the console it seems that the files are sent :
[14/Jul/2019 10:16:54] "GET /static/css/welcome_page.css HTTP/1.1" 200 3003
I restarted several times the tutorials from the beginning making sure I do each step exactly as described, nothing changes. When I begin with a new django project, the base django css is working before I add wagtail. I m using Python 3.6.8, Django 2.2.3 and Wagtail 2.5.1. What am I doing wrong ?
To answer #Dan Swain comment :
Settings.py file :
https://pastebin.com/zZqDesnr
Ok so simply my django-wagtail server was serving css but with an incorrect mimetype. My browser received the css but because of the wrong mimetype it didn t apply them
I had to add :
import mimetypes
mimetypes.init()
mimetypes.types_map['.css'] = 'text/css'
To my settings files and everything worked fine
One standard Wagtail folder structure includes a settings folder (not just a settings.py file). Inside the settings folder you would find base.py, dev.py, local.py, and production.py. You are using, instead, a plain settings.py file that is at the same level in the directory structure as your wsgi.py. Inside your settings.py you have a BASE_DIR declaration that is typically used in the settings folder setup:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
I think that your problem will be fixed if you change that line to:
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
I found missing 3 style files by F12 debugging. Copy the style folder to the target folder. From wagtail-master\wagtail\admin\static_src\wagtailadmin\scss to wagtail-master\wagtail\admin\static\wagtailadmin\css. That solve my style error.
if CSS is not working in admin panel in wagtail. you should check your nginx setup at first. in nginx there are should be such configurations:
location /static/ {
alias /home/path_to_project/project/staticfiles/;
}
please give attention, there should be alias not root

CSS is not working when accesing a view through controller

I am working with codeigniter. But CSS is not working even I use base url() function.
< link href="< ? php echo base_url(); ?>
application/views/vehicle/css/bootstrap.min.css" rel="stylesheet" media="screen" />
If I just echo base url(), it outputs
http://localhost/codeigniter/
My css is in
C:\xampp\htdocs\codeigniter\application\views\vehicle\css
Can someone please help me with this?
Your css file should be in publicly approachable directory.
Application directory (application or APPPATH) is not publicly reachable.
So your CSS file should be somewhere next to index.php file of your application.
It is common to have assets/css path started in your website root:
-application
-system
-assets
--css
---vehicle.css
-index.php
-.htaccess
And if you make your web application code that uses CSS files dinamicaly regarding of route used, you can resolve it by adding more related subfolders:
-application
-system
-assets
--css
---vehicle
----style.css
-index.php
-.htaccess
This way, after url helper is loaded, you could reach css link with:
<?php echo base_url('assets/css/vehicle/style.css');?>
Eventualy you should include assets location in .htaccess file enabling Apache server to allow reading of it.
Maybe because of the ">" closing tag before "media".
Maybe you could try with relative path. So use as many "../" as needed to go back into parent folder untill you reach root dir (if your php file is in a sub-folder) and then add the path to the CSS file.

Ruby on Rails, broken url() in css after concatenation

Situation
Use bower In .bowerrc
In bowerrc set directory vendor/assets/bower_components
In config application.rb I typed config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components')
Install gallery plugin called «fotorama», do it by bower
All files of plugin «fotorama» now storage in this directory "/vendor/assets/bower_components/fotorama"
In manifest css file application.css I type *= require fotorama/fotorama.css
In layout file I typed <%= stylesheet_link_tag "application" %>
Starting server rails server — everything is ok. In source of generated page I see <link href="/assets/fotorama/fotorama.css?body=1" rel="stylesheet" />. This css file has this line .fotorama__video-play {background: url(fotorama.png) no-repeat}, and many other lines where uses url for file "fotorama.png", and it is ok, browser try to find this png file near the css file, and successfully do it.
Stop server, precompile all essets rake assets:precompile, and then run server in production environment rails server -e production
Problem
In production, all my css files concatenated, and in source of page it looks like this <link href="/assets/application-2d31fc33890d01b046194920367eb3d4.css" rel="stylesheet" />, and still this file has this line .fotorama__video-play {background: url(fotorama.png) no-repeat}. Now browser trying to find png file here http://localhost:3000/assets/fotorama.png, but it isn't here, it isn't anywhere, because, I don't know why, there is no "fotorama.png" in "public/assets" folder.
Questions
Why pictures didn't transport from "/vendor/assets/bower_components" to "public/assets"
Have you got an idea, what can I do to solve my problem? Important, that I don't want to change urls in css manually, programatically — ok.
Excuse me for my english, and thanks for everybody who going to help me.
Solution and answers
Only files from "app/assets" transports to "public/assets" by default. To transport images from "/vendor/assets" type in "application.rb" this code config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
Task for gulp: if you see some changes in "bower.json", take all main files of bower components by npm moudle called "main-bower-files". Generate a manifest file with each css file with .erb extension, and save it "app/assets/stylesheets/bower_components_manifest.css"
This task continue: in every main css files, by npm module called "gulp-css-url-adjuster", add before every url <%= asset_path ' plus path to directory, and after ' %>. url("fotorama.png") >> url("<%= asset_path 'fotorama/fotorama.png' %>"). Add .erb extension and save.
In "app/assets/stylesheets/application.css" I add * require bower_components_manifest.
One of the other solutions, use gem "bower-rails". But I don't like it, because in some plugins in bower I need override some "main" files, and gem "bower-rails" can't do this, npm "main-bower-files" can. And I like to save my workflow for everything what I have done before start include my code to rails, gulp, bower.

Resources