I'm building a website in Rails after not having used it in a very long time, a small part of the site will be a simple blog structure for news. I started with the basic post/view structure that rails generates, albeit altered a bit to make it a little more specialized. Everything is working fine except one error that I keep running into, within posts I need to be able to create links and images (duh) but just throwing html into my posts means they wont render and the html tags just show up (e.g. stuff etc) and the same goes for ruby tags (which I assumed would be so since its post-parse when it is being posted. I assumed this was because rails was sanitizing the posts when they were being created somewhere along the line but couldn't find any code that was doing this... I'm sure someone has run into this problem before but I can't find anything about this anywhere, any help would be great!
Thanks
This is most probably due to rails escaping HTML tags for safty. You could use raw method to overcome this
Ex: <a htef='http://google.com'>google </a>
<%= raw("<a htef='http://google.com'>google </a>")%> #will render the hyperlink
HTH
Related
I have a question regarding the latest core web vitals. How exactly it works on a HTML static website with a lot of pages? I made some tests, but the results which I get are really weird. Are these results related to the whole website or only to that page, in my case the frontpage? I also removed a lot of elements to test that, but the result wasn't changes.
And another thing which confuse me .. on one side, google recommend to avoid shifts, but when there are adsense (which is also a product from google), there must be a shift. So, how you are handling that?
Well I have a website, and I wanted to add a feature of an articles that I write sometimes for my business, my website is only one page so i want some free plugin, that I will be able to add content without using any code every time, and not start creating a full php website. any idea guys?
thanks..(the website is a full html no joomla or wordpress)
The question is absurdly broad, but we can tackle this as best as possible. We're going to assume the following things here:
You know CSS
You know HTML
As such, you're probably aware of how to create tables, columns, and such. So I'll operate under the assumption that you know how to design and create your pages.
Your best bet is to use a PHP include function (or several) that references a file. As such, your index.html will need to become index.php. It's only a single line of PHP so it shouldn't cause issue, and the line itself is fairly simple.
<?php include 'directory/file.html';?>
Now you'll obviously need to either create your own directory or name your own files. The files referenced do not need to be PHP nor do they need <html> or <body> tags. They'll be included and styled in the page as is, wherever the PHP include is placed.
This means that you can just edit your included file(s), which will allow you to move these posts around your page as needed simply by moving your PHP function. If you precede the PHP line with a <p> tag, you don't even need to add tags into the included file, although I'd recommend doing all of your tagging in the included file rather than the index.php
If there's anything else, comment and let me know. Hope this helped to some degree! Again, broad question.
This might sound like a very strange question but I'm wondering if it's possible to take only a small part of an original website and use that part on a new website without having the direct access to the database?
The site displays latest entries of items added to a database and it contains a lot of stuff that is unnecessary which I want to get rid off. The new site should supposedly only display the div with the id "content" and everything in it. Here is the site: link to site
I've tried to inspect the elements on the site and copy the html code but the problem is that it converts all the added items to string instead of loading it directly from the database.
The reason why I want to learn how to do this is nothing more than an interest in how it can be done that could be helpful later on.
What you can do is two things. If you want to get the data from a website that doesn't provide an API you can write an HTML parser to grub the desired data. Note that this is likely to break in the future, if the original site makes any changes to the html.
If you want to display a part of the website as it is you can use an iframe to embed the original site to your site and then use js to hide what you don't want to show. See here for more info.
I'm creating a Shopify store for a client who does not obviously know coding. He will need to update content on the website (and I have coded some pages with certain layouts (in the html part of the content) so when he types his content it often breaks our design)
As an alternative solution, I'm thinking of using the blog feature.
I know Shopify lets us create a page with only a certain blog, but what it does is show up in the URL - as a ...blog/cocktails.
That is not good for the end user, because I merely want it to be a page that calls the blog articles from this blog. I'm unable to find a way to do it.
I tried replacing blog.content with blog['cocktail'].content and etc..
but it didn't do anything.
Alternatively are there any suggestions how you can design a page and let clients add their own content just by typing (for instances where its a list of recipes for example)?
I think it would be best to create a custom page template same as blog page.
It will solve your all problems(i think) because first your url problem will be solved by it user has to just assign a template from backend.
Second one most important user can update its content from backend and it will not disturb your html.
If you still have problems just customise html and css.
I hope it will help you.
I have a simple html/css-only static website on which I would like to add a blog. Comments and RSS aren't necessary.
Now, how do I do that, without having to write all my entries in pure html?
My website consists of a vertical menu and an area to the right of it, where all the content goes on each page. I would like a blog inside that area on the blog page, so a blog on a separate page with its own layout is not what I'm looking for.
Googling this doesn't really help me much since the majority of the hits are on sites offering blog services.
Thanks in advance, I hope I'm not being too difficult. Please leave some feedback on my question if you think there are things I should have tried out before asking.
If i understand what you want the answer is that ist is not possible in pure html and css. With only Html and css you can not make a blog (if you dont want to edit the source everytime you write an entry and have to make a new file for each entry and so on).
You need some code (php or so) that is able to store and load the entrys into your site.
Html and css are not meant to make things working. With Html you define the elements so that they are structed and then with css you "style" your work. But for the task of a blog (i think you want an editor for the text on the site, the ability to edit, delete, more than one site and so on) you need something like php or aps.net that is able to "interact".