I have an html code with rails. I need to translate it into slim format, I changed the file format, translated it with a convector and tried to run it as a result the links do not work, can you tell me why?
head.html.erb
<section id="header">
<div class='navigation-panel'>
<button class='burger-button' id='header-burger-button container' onclick='burgerAction()'>
<%= image_tag("header/burger.png") %>
</button>
<button class='contact-us-button burger-hidable container' onclick='scroller("contact")'> CONTACT US </button>
<div class='menu-container burger-hidable container' style='display: none;'>
<%= image_tag("header/menu.png") %>
</div>
<div class='nav-links burger-hidable' style='display: none;'>
<p onclick='scroller("header")'>Home</p>
<p onclick='scroller("services")'>Services</p>
<p onclick='scroller("how-we-work")'>How We Work</p>
<p onclick='scroller("team")'>Team</p>
<p onclick='scroller("why-us")'>Why Us</p>
<p onclick='scroller("portfolio")'>Portfolio</p>
<p onclick='scroller("contact")'>Contact Us</p>
</div>
</div>
</section>
head.html.slim
section#header
.navigation-panel
button.burger-button id=("header-burger-button container") onclick="burgerAction()"
= image_tag("header/burger.png")
button.contact-us-button.burger-hidable.container onclick="scroller(\"contact\")" CONTACT US
.menu-container.burger-hidable.container style=("display: none;")
= image_tag("header/menu.png")
.nav-links.burger-hidable style=("display: none;")
p onclick="scroller(\"header\")" Home
p onclick="scroller(\"services\")" Services
p onclick="scroller(\"how-we-work\")" How We Work
p onclick="scroller(\"team\")" Team
p onclick="scroller(\"why-us\")" Why Us
p onclick="scroller(\"portfolio\")" Portfolio
p onclick="scroller(\"contact\")" Contact Us
I believe the problem is the escaped quotation inside the onclick attributes.
Consider using single quotes inside your attributes' double quotes: onclick="scroller('header')".
You can read more about escaping and quoting attributes here: https://www.rubydoc.info/gems/slim/frames#Output_without_HTML_escaping___
Related
I am using scrapy to extract an item list into an array with the following info:
<div class="row">
<div class="col-md-4">
<p class="title">title info</p>
<p class="content">txt info</p>
</div>
<div class="col-md-4">
<p class="title">title info</p>
<p class="content">txt info</p>
</div>
</div>
Somehow my syntax seem to be wrong:
>>> response.xpath('//div[#class="row"]/div[#class="col-md-4"]/p/text()').extract()
[]
There might be another row class ahead of this item
You want to scrape https://www.watchmaster.com/de/bvlgari/automatic/bb38sl-auto/UELG3X5E7R page.
For example to collect Details from page it is better to add extra parent selector like here: response.css("div#watch-details-tab div.row div ::text").extract() to avoid collecting data from alike structures.
If you need to collect it by feature, try:
for row in response.css('div#watch-details-tab div.row div'):
k = row.css('p.title::text').get()
v = row.css('p.content::text').get()
# and then your logic for this data
I need to render a page after a formencode validation.
html = render('/billing_errors/index.mako')
This page contains tabs that are anchored.
<ul id="tabs" class="tabs">
<li>Retail</li>
<li>Wholesale</li
<li>K Rooms</li>
</ul>
<div id="kroom">
<div class="span-6">
<br />
</div>
<div class="span-12 last">
<fieldset>
<legend>Insert BT Op-Assist Room</legend>
%if h.auth.authorized(h.auth.is_infinite_billing_manager):
<form method="post" action="${h.url(controller='billing_errors', action='save')}">
<%form:text label="Account" name="acctgrpid" />
<%form:text label="Room" name="accountid" />
${h.hidden('action', 'bt op- assist')}
<%form:okcancel
positive="Insert"
negative="Cancel"
negative_url="${h.url(controller='billing_errors', action='index')}"/>
%endif
</form>
</fieldset>
</div>
</div>
This is what i'm currently doing after formencode returns an error.
try:
values = dict(request.params)
form_result = schema.to_python(values, state=Struct(session=Session))
except Invalid, error:
form_results = values
form_errors = error.error_dict or {}
return htmlfill.render(html, defaults=form_results, errors=form_errors)
how can i get htmfill.render() to return the and display the named anchor.
You need only to specify the _achnor argument
e.g
h.redirect_to(controller='myController', action='myView',
id=user_id, _anchor="ui-tabs-2")
im currently trying to grab an avatar from an html web source, probllem is theres several img sources and containers that have the same name, heres the current part i need
</div>
<div class="content no_margin">
<img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />
<br />
<a class="link" href="http://sharefa.st/user/donkey">Uploads</a><br />
<a class="link" href="http://sharefa.st/user/donkey/favorites">Favorites</a><br />
</div>
</div>
<div id="content" class="left">
<div class="header">
Uploads
</div>
<div class="content no_margin">
<div class="profile_box">
<div class="profile_info">
Now the part i need to grab is:
<img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />
this image, Any help and id be grateful!
try:
Dim wb As New WebBrowser
wb.Navigate("")
Do While wb.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
Loop
wb.DocumentText = HtmlString 'Your Html
For Each img As HtmlElement In wb.Document.GetElementsByTagName("img")
If InStr(img.GetAttribute("src"), "avatar") Then
MsgBox(img.GetAttribute("src"))
End If
Next
You appear to be attempting to parse HTML 'by hand'. Please don't.
http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html
see this question for some alternatives How do you parse an HTML in vb.net
Use regular expression to find what you're looking for:
http://msdn.microsoft.com/en-us/library/twcw2f1c.aspx
The example code demonstrates pretty much your scenario.
I'm brand new to rails (and coding in general) so I've a quick question on retrieving images from a database
Running rails 3.2.8
I have a list of products, code, description, price and product_image in the database, The product images is stored as 123.jpg in the database and the image itself is stored in app/assets/images folder
In my view I have the following code
<div class="center_content">
<div class="center_title_bar">Latest Products</div>
<% #camera_catalogues.each do |camera_catalogue| %>
<div class="prod_box">
<div class="top_prod_box"></div>
<div class="center_prod_box">
<div class="product_title"><%= camera_catalogue.model_description %></div>
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
<div class="prod_price"><span class="reduce">350$</span> <span class="price"><%=number_to_currency(camera_catalogue.price, :unit =>"€")%> </span></div>
</div>
<div class="bottom_prod_box"></div>
<div class="prod_details_tab">
<img src="assest/cart.gif" alt="" title="" border="0" class="left_bt" />
<img src="assest/favs.gif" alt="" title="" border="0" class="left_bt" />
<img src="assets/favorites.gif" alt="" title="" border="0" class="left_bt" />
details
</div>
</div>
Everything displays correctly except that the image is not retrieved from the database
which is this line
<div class="product_img"><%= link_to (image_tag camera_catalogue.product_image),camera_catalogue %></div>
Does the image in the database need to be saved with a different url. i.e. instead of 123.jpg it is saved as assets/123.jpg
or is there some other error in my code.
Help/advice greatly appreciated :)
Use it like this
<div class="product_img"><%= link_to (image_tag (camera_catalogue.product_image)),camera_catalogue %></div>
I guess it will work for you. You need not use 'assests/image_name'
I'm still a newwbie in ASP.Net and don't get how to fix the following problem.
I need rich text to be published on my project. I added NicEdit because it seems to be easy to use.
So, as foreseen, i got an error from the server.
A potentially dangerous Request.Form value was detected from the client(compteRendu="blablbab<br><br>test<br>").
I tryed to fix it by using htmlencoder, but I failed at using it.
What I did :
<script type="text/VB">
htmlEncode {
model.compteRendu = HtmlEncode(model.compteRendu)
}
</script>
#Using Html.BeginForm(IsPost)
#Html.ValidationSummary(True)
#<fieldset>
<legend>meeting</legend>
#Html.HiddenFor(Function(model) model.idmeeting)
<div class="editor-label">
#Html.LabelFor(Function(model) model.compteRendu)
</div>
<div class="editor-field">
#Html.TextAreaFor(Function(model) model.compteRendu)
#Html.ValidationMessageFor(Function(model) model.compteRendu)
</div>
<p>
<input type="submit" value="Save" onclick="htmlEncode"/>
</p>
</fieldset>
End Using
So, what have I done wrong? I also tryed to do this inside the controller but I didn't find any method which was supposed to encode the Html
' POST: /Meeting/Edit/5
<HttpPost()>
Function Edit(meeting As meeting) As ActionResult
meeting.compteRendu = HttpEncode(meeting.compteRendu)
If ModelState.IsValid Then
...
ps : I'm not a native english speaker, sorry if my english sucks.
edit :
For the moment, I'm not needing more than something that allows me to replace my "new lines" by .
So, I've found that I could do iit like that :
#Html.Raw(meeting.compteRendu.Replace(System.Environment.NewLine, "<br />"))
For the moment, it's ok for me. But I'm not sure, maybe I'll need to create text with colors, and so on. So if you've an idea on how I can send validated rich text to my database, I'll be very happy.
You could decorate the compteRendu property on your view model with the <AllowHtml> attribute:
<AllowHtml()>
Public Property compteRendu As String
This will accept any characters in this property. Inside your view you don't need to do any encodings:
#ModelType Meeting
#Using Html.BeginForm(IsPost)
#Html.ValidationSummary(True)
#<fieldset>
<legend>meeting</legend>
#Html.HiddenFor(Function(model) model.idmeeting)
<div class="editor-label">
#Html.LabelFor(Function(model) model.compteRendu)
</div>
<div class="editor-field">
#Html.TextAreaFor(Function(model) model.compteRendu)
#Html.ValidationMessageFor(Function(model) model.compteRendu)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
End Using
Neither inside your controller action:
' POST: /Meeting/Edit/5
<HttpPost()>
Function Edit(meeting As meeting) As ActionResult
If ModelState.IsValid Then
...
End If
...
End Function