Use custom font in GitHub pages - css

Trying to change the font in styles.css file in GitHub pages, here is the code:
#font-face {
font-family: "Samim";
src: url("/resources/Samim.ttf") format("truetype");
}
Here is the directory and font saved in resources folder
project files directory
the problem is that font doesn't change, also tried to move the font to main directory but no change, it also works properly locally on vscode live preview.

You have to provide the Relative Path to the file,
For Example Take This Directory Structure:
- root
- system-files
- vahid
- github-pages
- resources
- Samim.ttf
- README.md
- index.html
- styles.css
Here the "root" is the Drive On which your Operating System is Stored On, and "system-files" contains your Operating System's Important Files and finally you have this folder "vahid" which contains the user's files, and inside "vahid" you have "github-pages" folder where all your github pages code is stored.
In Path the / means the root, in Windows take this as like if you open C:\ in Windows Explorer.
And this period . means current directory, and when you use ./ instead of / you're specifying a path to a file/folder in current Directory.
Now when in my styles.css if I use this Path /resources/Samim.ttf what it means is "Samim.ttf" File in inside of the "resources" folder in the root directory.
Did you notice something? Let me try to show this path in the directory Structure.
- root
- resources
- Samim.ttf
As you can see the Path we specified doesn't exist, try to compare it to the Real Directory Structure Given Above.
So instead of using / we have to use ./ because the "resources" folder is in the same folder as of the "styles.css".
So you have to replace your Absolute Path with Relative Path, which will be this:
./resources/Samim.ttf
Read More About Relative And Absolute Path At LinuxHandBook.com

I changed the directory path like this:
url("./resources/Samim.ttf")
just added one . after /, idk why but it works now!
also trided ../resources , ..resources and /resources and didn't worked.

Related

Uploads in Symfony's var directory not accessible

I'm trying to upload files into 'var' directory (successfully). But when I want to take this one file from 'var' I only can observe No route found for "GET /var/uploads/images/....
Structure:
- app
- bin
- src
- var
- cache
- logs
- uploads
- images
- vendor
- web
For saving my files I'm using: '%kernel.project_dir%/var/uploads/images'
For order to take file: '/var/uploads/images/' . $fileName;
Where're my mistake?
P.S. Moreover I try to use volume (I'm using docker) in my docker-compose file like this: - ./data/cabinet/uploads/images:/data/www/cabinet/var/uploads/images
And, unfortunately, no one file didn't copy to this directory. What's wrong?
Thank you!
Since the document root is pointing to the web directory, there's no possibility for path ../var to be accessible. Either store uploads inside the web directory or create a symlink inside it pointing to the var/data/uploads:
// since I don't know your path tree inside the container
// I assume whole application is installed inside /var/www/html
// and this is the default working directory
docker-compose exec YOUR_CONTAINER_NAME \
ln -rs /var/www/html/var/data web/var
Bear in mind that if you are using Apache webserver, the FollowSymLinks option has to be enabled, but most probably is.
As for the second question, most likely you mapped an invalid directory, I guess this should be:
// yet again I assume whole application is inside the /var/www/html
./data/cabinet/uploads/images:/var/www/html/data/cabinet/uploads/images
Is this some kind of production anyway? If it is not and this is merely a work-in-progress, then you rather should map your whole local directory as container volume. This is how it's usually done in dev mode, so the mapping would be:
.:/var/www/html

Can linter-flake8 ignore files by using a project-wide .flake8rc?

I'm using Atom and linter-flake8 for my project. I have a set of huge generated Python files and I want them ignored by linter-flake8. These files are placed in a folder called generated/, inside the project root folder. At the same level with the generated/ folder, I placed a .flake8rc with the following content:
[flake8]
exclude=generated/
and configured linter-flake8 to use this file (via Preferences in Atom). However, it still parses those files. What am I doing wrong?
PS: If I run flake8 --exclude=generated/ . in bash, in the project root folder, it works fine and ignores my files.

Relative paths when uploading image with Symfony 1.4 on shared hosting

I've had a running website on VPS which I've built using Symfony 1.4.20 but then I decided to move it to a shared hosting and the problems arised. I think I've done the essential parts since it's accesible now but when I try to upload any images via backend it shows error message as in the ss below:
Failed to create file upload directory "/../public_html/img".
img folder, which I try to upload the image into, is already created and inside the public_html folder. I also set public_html and img folders' chmod as 777.
When I use the url_for function it shows the correct url of images from public_html/img folder, for example: domain/img/imagename.png
Here's my configuration:
/
/app (Everything except web folder is here)
/public_html (I put everything inside the web folder into this folder)
My ProjectConfiguration.class.php file:
require_once dirname(__FILE__).'/../lib/vendor/symfony-1.4.20/lib/autoload/sfCoreAutoload.class.php';
public function configureDirectories()
{
sfConfig::set('sf_web_dir', '/../public_html');
sfConfig::set('sf_all_images_url', '/img');
sfConfig::set('sf_all_images_dir', sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'img');
}
And in my backend.php:
require_once(dirname(__FILE__).'/../app/config/ProjectConfiguration.class.php');
So when I want to save any image I give the relative path like this:
$filepathImage = sfConfig::get('sf_all_images_dir') . '/' . $filenameImage;
It used to work back in the day when my website is configured as default on the private server but now I'm stuck, I need to fix this as soon as possible, so please help me :) I didn't do any url rewriting. If you need further information about any part of the project I can show it. Thanks.
maybe you need to dump ur $filepathImage and see if it's the right path

Compiling assets for wordpress theme

I'm working on a WordPress theme (more specifically: a wordpress theme boilerplate) which makes use of SASS (and lots of other technologies). My SASS files are within assets/sass. My problem is: how/whereto compile them?
Compiling them into the root directory doesn't feel right, since it gets bloat up - and it is already pretty big (with Grunt, Bower, etc.). But the asset path problem (see below) would disappear.
Compiling them into a directory (like temp or whatever) wouldn't bloat up my directories but lead to the asset path problem.
The asset path problem:
elem { background-image: url('images/foobar.png'); }
The path would be correct if the compiled sass file in assets, nowhere else. assets/images/foobar.png would just work in the root directory.
An important note: it's possible to create a distributable version of the theme with Grunt, where, amongst other things, all styles are concatenated with the style.css file in the root directory. The generated dist directory then contains only files which should be uploaded to a server or used for distribution (no build files, no sass, no coffee, etc. - just compiled and "finished" files).
Any ideas? Thanks.

Image referencing in css file - what am I doing wrong?

If an image shows up in a div when I code:
background:url(/imgs/crowd1.jpg)
in the css, but is doesn't when I code
background:url(imgs/crowd1.jpg)
what does that indicate I am doing wrong?
/ means that it the file or folder is in the root folder while without the / means that the file or folder is in the current directory.
Here is a brief description of other file paths:
./ means the current directory
../ means the parent of the current directory, not the root directory
/ is the root directory
myfile.text is in the current directory, as is ./myfile.text
../myfile.text is one level above you and /myfile.text lives in your root directory.

Resources