Odoo doesn't displays markdown images - python

I want to display a markdown(readme) file into an odoo view as a field, i'm using the parser mistune to parse the file into an html format; as a result, the text is displayed as expected, except for every images located in src/img folder for the odoo module structure.
(example of image: ![Capture](static/src/img/usecase.png))
I've tried with the html inspector and it says the image wasn't found, and when I hover it, the path is http://server-s551lb:8069/static/src/img/usecase.png and I find it weird because it's only the relative path to locate the image.
Any help or idea would be welcome:)

I've found by adding modulename/ before static from the relative path of the image :)

Related

Can't load image with html

I've been trying to upload an image in my webpage where i have multiple directories. I tried loading the image when the file was in the same directory as index.html. I tried loading the image when the file was in the directory templates and i even tried to make a directory images and upload it from there but nothing works. As you can see from the image, I copied the path and the relative path(i tried both) and put int "img src" but the image just won't load. The terminal says that it can't find the image due to a 404 error and gets me a link but when i click the yellow link I am able to see the picture. What else can i try?
codespace
try relocating your image where your html file is and changing the type of file
index.html resides in /templates and your relative path would lead to /templates/workspaces which obviously does not exist.
You can do something like
<img src="slika.jpg">
if the index.html and slika.jpg are in the same directory.

Image in Jupyter Notebook ipynb doesn't show up in GitHub private repo but the same code works with public repo

I have a Jupyter Notebook .ipynb file in my GitHub repository. It is supposed to show an image via the following markdown code:
![image](image.png)
The image does show up when the repository is public. However, when the repository is set to private, only the alternative caption "image" is visible and the image doesn't load. If I right-click on it and select "View Image", the image loads fine.
The issue also doesn't exist for .md Markdown files: the same line above works for public and private repos.
There is this answer which describes how to embed images into the .ipynb file, but that's not what I'm looking for. I want to display the .png file dynamically.
As of 2015, Jupyter notebooks are rendered on GitHub using nbviewer. From this blog post they state:
Second, because of security concerns, some features available on nbviewer will not be available on GitHub. For example, GitHub will not render any dynamic output display that uses JavaScript, custom CSS, and most custom HTML embedded in Markdown or in outputs. When this is the case, and GitHub cannot fully render your notebooks, you will see an icon that allows you to view the full notebook on nbviewer.
An issue thread has some users saying that logging out/logging in will resolve the issue. Others say it is resolved over time. But there seems to be no recognized solution.
I struggled a lot, than at last was able to fix it.
Use "/" instead of "\" in image path
If you are using width field for png image file than .png should be small, width="200" number should be in quotes, img should be closed like this ->img src="Image/neuron-1.png" width="300" />
I have tested most of the comments; however, only the following works for me:
Build the folder in the same repository with the image name.
Create a file .gitkeep in the Image folder.
Upload your images in this folder.
Add address like: <img src='Image/name.PNG' />
Note: building Image folder is necessary.
When I made my repo public, Github required me to confirm my credentials, but as soon as it was public, the images rendered. It could have been either so I'd suggest either logging out / in or making your repo public (then taking immediately private again if need be).

Django doesn't show the CSS of my template

The problem is described in title. I have this template for a blog that I'm creating using Django.
When I open it normally, using double click over the HTML file, it looks like this:
But when I open it via url from the Django project, it looks like this
It only shows a green square (part of the css) but obviously can't open the css correctly.
Any idea to solve this?
In Django you don't open the HTML with double click on the file, you need to run the server first and open your site using the localhost (like you did in the second picture).
Judging by those images, are you sure you put the image in the static folder? In Django, the HTML files stays in the "templates" folder of your app and the css, javascript and images in the "static" folder.
If this answer doesn't help you, then you should post your code here, otherwise I can't find the problem.

How to access static image when using Plotly python API

Following the plotly tutorial on getting static images through the python api.
When I execute:
import plotly as py
py.offline.plot(data,
show_link=False,
image_filename='pandas-bar-chart-binned',
image='png')
My browser auto opens and I get both an HTML file in my parent directory and an image of the chart downloads from the browser, which is to be expected from the docs.
But if I execute:
import plotly as py
py.offline.plot(data,
show_link=False,
image_filename='pandas-bar-chart-binned',
image='png',
auto_open=False)
The HTML file is generated in my parent directory, but no image is produced. If I store it as a variable, I get a string that represents the location of the HTML file.
Is there a save_as function for offline, as there is for image?
import plotly as py
py.plotly.image.save_as(data, filename='pandas-bar-chart-binned.png')
I have found a handful of suggestions, but they all seem to point back to opening up a browser rather than saving directly through the file system.

Python pisa/xhtml2pdf messy rendering

In a django project, I want to generate an html page from a view and convert the html/css generated to pdf. I am using xhtml2pdf for this (https://github.com/chrisglass/xhtml2pdf/blob/master/doc/usage.rst#using-xhtml2pdf-in-django).
Browser -> django view -> mysql DB -> django template -> html/css -> pdf
I have made sure that:
I am using a function (link_callbak) to convert all relative paths to a proper absolute ones so xhtml2pdf is able to retrieve all the images needed.
Instead of relying on a tag to include the CSS (which does not work) I have directly used #import function with an absolute path to the css file. (CSS not rendered by Pisa's pdf generation in Django)
The css file is taken into account as I find some style element in the output howver the pdf generated is very different from the html output. Images are all messed up (partly visible and partly just outside the document), forms are not respected, font size is not correct, <ul> are not properly rendered. Moreover, I had to remove a -moz-placeholder tag from the CSS as it was not properly handeled by xhtml2pdf.
Is there known issues of CSS interpretation with xhtml2pdf ? Is there restrictions ?
I already spent a lot of time customizing the CSS file to make it work on Chrome/Firefox and IE7, and I don't want to spend another round on adapting it for xhtml2pdf. Is there a reliable solution to convert an html/CSS templated through django to pdf ? Even a special type of link to call the 'print pdf' function of the browser would do...
And no, I don't want to use ReportLab and draw squares and circles, thank you !

Categories