I deployed my project to web faction, set the static and media settings. Initially media files not showing, only the static files are shown in the site. But I can see the media files in my local system.
I used filefield not imagefield during model creation. Is that a problem?
is tried both ways:
<img src="{{MEDIA_URL}}{{i.cover_image.url}}" alt="">
<img src="{{i.cover_image.url}}" alt="">
These are settings:
settings.py
STATIC_URL = '/static/'
STATIC_ROOT = '/home/{}/webapps/testapp_static/'.format('user')
STATIC_FILE_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL= '/media/'
And i added this setting to myproject urls
urls.py
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Please help me where i went wrong. Is there any additional settings or path is missing. i want to view media files in my template.
I Put MEDIA_URL ='http://www.yoursite.com/static/' in Settings.py file and in template i used
<img src="{{ MEDIA_URL }}{{ obj.image.url }}" >
now its working properly in production. For local, change media url to /media/.
Related
I've looked around and I'm sure this is common but can't seem to get the right answer.
I've just recently set up a Codeigniter 3 project on my localhost and a migrating some Codeigniter 2 code.
The index.php file is a bit different.
I can get the project up and running except the main folders references in the index.php file such as APPLICATION and others I've added like "ASSETS" etc are loading like this:
<link href="http://[::1]/projectOne/E:\public_html\projectOne\assets\css\style.php?1537317115" rel="stylesheet" type="text/css" >
Even when I set a base_url:
<link href="http://localhost/projectOne/E:\public_html\projectOne\assets\css\style.php?1537317115" rel="stylesheet" type="text/css" >
I've checked it wasn't just the folders I added by echoing out the APPPATH variable:
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
echo APPPATH;
Which produces:
E:\public_html\projectOne\application\
What am I missing here?
How do I get my paths to folder set in the index.php to just use the project root, and not the whole filepath on the computer?
Figured it out. For anyone else that hits this issue.
This new part in CI3:
if (($_temp = realpath($application_folder)) !== FALSE)
{
$application_folder = $_temp;
}
Allows you to more securely/easily have your application folder outside of the website root.
My additional ASSETS folder was then showing the full web path which you obviously don't want.
So commenting out this part leaving only:
$application_folder = strtr(
rtrim($application_folder, '/\\'),
'/\\',
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
);
And then setting you base_url value in the config.php file gives your CSS, JS and IMAGES proper site relative paths.
How can I override the favicon.ico in the Hybris using an addon?
I tried to overwrite the property img.favIcon but it doesn't work
As favicon.ico is rendered through master.tag of the storefront, so it would better you directly change it in the storefront itself, otherwise, you need to create master.tag file in your addon and also need to override all its references so it starts pointing to your addon master.tag file.
Simplest
Just override OOTB favicon.ico with your favicon.ico in the storefront. It's done.
Using javascript (Not recommended)
Copy your favicon.ico at the below-mentioned path in your addon (e.g myaddon)
/myaddon/acceleratoraddon/web/webroot/_ui/responsive/common/images/favicon.ico
Add below javascript in your addon js file (e.g. myaddon.js)
(function() {
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'https://www.yoursite.com/_ui/addons/myaddon/responsive/common/images/favicon.ico';
document.getElementsByTagName('head')[0].appendChild(link);
})();
Build and start the server
ant all && hybrisserver.bat start
I found the solution I copied the Theme.properties to the addons and changed the path
In my directory I have:
shop.rb (App < Sinatra::Base)
lib directory - Ruby models inside
views directory - erb files inside
Gemfile
Where should I place my style.css ? I tried every place possible, I created public folder and tried with also every possible place, but my styles doesn't work.
In layout I have:
<link rel="stylesheet" href="/style.css"/>
I tried also with:
<link rel="stylesheet" href="style.css"/>
It might be because the app is not configured to find the public directory/ First make sure the public directory exists relative to the main entry file of your application (assuming shop.rb) and use the following configuration:
class Shop < Sinatra::Base
configure do
set :public_folder, File.expand_path('../public', __FILE__)
set :views , File.expand_path('../views', __FILE__)
set :root , File.dirname(__FILE__)
end
get '/' do
erb :index
end
end
Once set up, Sinatra should now know where to find your public directory and you can just include the asset file like this:
CSS:
<link rel="stylesheet" href="/style.css"/>
Image:
<img src="/img/background.png" alt="Image" />
JavaScript:
<script src="/js/main.js"></script>
I am using doxygen 1.8.9.1 and want to use AsciiMath in the hmtl output. It requires me to use a new config file, i.e. http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML. However, the configuration "MATHJAX_RELPATH" can only set the root path of mathjax.
How could I change the config to mathjax? Thanks for any suggestions.
EDIT:
I have tried to use MATHJAX_CODEFILE to change the config file "config: ["local/local.js","MMLtoHTML.js"]", but don't work for me. The URL should be modified, not just the configuration files. (i.e. MathJax.js?config=AM_HTMLorMML).
BTW: The render html should be change from \[sum_(i=1)^n i^3=((n*(n+1))/2)^2\] to `sum_(i=1)^n i^3=((n*(n+1))/2)^2`.
One solution is to modify MATHJAX section of footer.html in the Doxygen folder.
For example, use this to modify the url to MathJax.js?config=local/local.js
<!-- BEGIN MATHJAX-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" src="../mathjax/MathJax.js?config=local/local.js"></script>
<!-- END MATHJAX-->
The $mathjax line of header.html should also be deleted.
I'm looking at the Compass-Sinatra starter file on GitHub. Is there a way to set the output_style for an scss file in Sinatra? Ideally I would like to set the style to :expanded when in development.
I think I'm having trouble understanding how sass(:"stylesheets/#{params[:name]}", Compass.sass_engine_options ) works and where I can set those options.
I found that adding the output_style setting to the compass.config file works for changing the output_style. It can either go in the if defined?(Sinatra) block or in the configuration block at the bottom of the compass.config file.
# compass-sinatra-starter/config/compass.config
if defined?(Sinatra)
# This is the configuration to use when running within sinatra
project_path = Sinatra::Application.root
environment = :development
output_style = :expanded # This is where you can set the output_style
else
# this is the configuration to use when running within the compass command line tool.
css_dir = File.join 'static', 'stylesheets'
relative_assets = true
environment = :production
end
# Or if you wanted to have the output_style set for all environments(?)
# This is common configuration
output_style = :compressed
sass_dir = File.join 'views', 'stylesheets'
images_dir = File.join 'static', 'images'
http_path = "/"
http_images_path = "/images"
http_stylesheets_path = "/stylesheets"
Note: stop/start the server if you change the settings if you don't see the change.
For example, I have a styles.scss file in views/stylesheets/styles.scss then if I go to http://localhost:4567/stylesheets/styles.css I'll get the .scss file compiled in the browser to .css. Changing the output_style, start/stop the server the .css output_style changes. I don't know if using reloader would work, but it might avoid the stop/start?
I found a couple of other good resources.
Andrew Stewart has a blog post and a GitHub template
Originally I was trying to learn about media queries in Sass(scss) with Sinatra and found a great video Ben Schwarz posted, but it doesn't go into the nitty gritty of setting up. It's more about the media query. Ben also has the source on GitHub.
But it seems like AssetPack is the best way to go for serving assets.