Include html pages with Google Closure - html

I'm working with Google Closure. I'm trying to include some html files in another one. Just like A.html import B.html and C.html, but actually, I don't get how to do that.
Can anyone could give some orientation please?
Thx in advance.

As far as I know you cant "include" html pages like that. The options you got is:
1: use ajax to fetch content
http://docs.closure-library.googlecode.com/git/closure_goog_net_xhrio.js.html
http://www.googleclosure.com/google-closure-ajax/
2: Google closure templates
https://developers.google.com/closure/templates/?csw=1
3: Use a serverside language like php to include your file.
http://www.php.net/manual/en/function.include-once.php

I really don't understand.
1) Have you HTML in JS and u don't know how to join it?
try goog.dom.appendChild(parent, child)
2) You don't know how to get it into JS?
You have to send it from server, or If I were in your shoes... use soy templates

Related

Scape data after login rvest

Please help me.
I'm trying to scrape the split table but actually I can't do and I don't understand why.
This is the url:
https://www.strava.com/activities/1983801964
This is the credential to login:
email=trytest#tiscali.it
password=12345678
This is my code:
pgsession<-html_session("https://www.strava.com/login")
pgform<-html_form(pgsession)[[1]]
filled_form<-set_values(pgform, email="trytest#tiscali.it", password="12345678")
submit_form(pgsession, filled_form)
page<-jump_to(pgsession, "https://www.strava.com/activities/1983801964")
page%>%html_nodes(xpath='//*[#id="contents"]')
And I get {xml_nodeset (0)}
I tried everything, also
page%>%html_nodes("body")%>%html_text()
But I can't get this information, please help me!!
Thanks in advance
I cannot find the split data in the HTML. Therefore, it may not be possible to scrape the splits from the HTML like this.
Alternatively, you can download the raw activity data. Link: https://support.strava.com/hc/en-us/articles/216918437-Exporting-your-Data-and-Bulk-Export
Edit: you may also be able to use this method to download Strava data: https://scottpdawson.com/export-strava-workout-data/
Edit 2: The splits are contained in a DIV called "splits-container". But, the source HTML is likely modified by javascript after the page is loaded. This means you will probably not be able to scrape the data without running the javascript first. Hope this helps.

Dynamically load an entire angular app

So I have a curious situation and I don't think it's going to work, but I figured I'd ask in case it is and someone knows how to. I am using a 3rd party website to create marketing funnels. You can add your own custom html and javascript, but it parses out the html in a rather unfavorable manor. Basically you specify an element on the page and it appends it as a data attribute and dynamically loads it into the DOM. Since this is happening this way, my app isn't being initialized because it's not in the DOM on page load. Is there a way to make this work? I'll explain a little deeper my configuration.
I add custom html such as:
<div data-ng-app="AppName"><div data-ng-controller="ControllerName"><div>perform controller logic here</div></div>
As you can see, this needs to be in the DOM for the app to initialize and, well work. Is there a way to initialize the app after the page has loaded dynamically? I can add my own JS files in the custom html field, but thats about as far as I can go for customization. Any help is appreciated!
Maybe you should execute angular's bootstrap function manually in your script after the required dom loaded.
var app = angular.module('appName', []);
app.controller([...]);
angular.bootstrap(document.getElementById('divId'), ['appName']);
For more information, you can see this doc https://docs.angularjs.org/api/ng/function/angular.bootstrap

Scrape CSS to bulk-check responsiveness

I have a list of web domains and would like to check if they are built to be mobile-responsive. A fairly sure way to check this manually is to see if there are "#media" queries in the style.css.
I've used XPATH (IMPORTXML) previously to bulk-check for strings on webpages, but I don't see an obvious way of importing the css files in bulk and search for a string within them. Is there a way to do this? Ideally, I'd like to accomplish it in Google Sheets or with Google Apps Script.
Thank you!
You can use Google's Mobile-Friendly Test if you want to use a GUI.
If you want to use a REST API, try this (replace url parameter for what you want to test):
https://www.googleapis.com/pagespeedonline/v3beta1/mobileReady?url=http://facebook.com
This will return a JSON object. It will return lots of useful info, but if you are just looking for mobile friendliness, look for the true or false result here:
"ruleGroups": {
"USABILITY": {
"pass": true
}
Hope that helps!

html template without using php or rails ect

I am looking for a way to code html templates without using any "backend" languages like php or ruby/rails.
using JS could work but i have issues with my current javascript when i add nodes after the DOM is loaded.
the solution that would be ideal is if there is a preprocessor of some kind that i can compile into finished html.. something similar to SCSS but for html
just so i'm clear and i have enough content for stackoverflow..
i want partial.folders content to compile into index.html
partial.folder
menu.html
root.html
footer.html
|
|
V
index.html
Depends on "when" you want to parse the templates.
1) At runtime: you could try to use https://github.com/janl/mustache.js - javascript Logic-less templates
2) At build time: I would suggest using nodejs+Grunt (http://gruntjs.com/) + grunt-preprocess (grunt plugin)
I found an answer to my own question. a program called codekit worked exactly how i wanted it to. thanks for the help! http://incident57.com/codekit/

How to include a HTML in JSP at runtime?

I need to include html or image in a JSP at runtime. I will come to know about the jsp filename at the time of runtime. So I can't able to make the change for a JSP include.
How can I do this?
I am not sure what you mean by runtime? I have done something maybe similar. In the controller I do. model.addAttribute("jspContent", "test.jsp")
And then in the containing jsp file :
<jsp:include page="${jspContent}" ></jsp:include>
Edit:
Read your comment. I guess then it depends on what other technologies you are using. You could add the name to be included to the session and then read it in the Controller that is receiving the redirect. Adding it to the model and clearing from session. Or if you happen to use Spring I just yesterday got to know about this: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-flash-attributes
Edit2:
I meant something like this, I am not entirely sure if it's suitable, but it's an idea :)
In the controller that is redirecting you do something like this:
session.setAttribute("jspContentFromRedirect", "test.jsp");
servletResponse.sendRedirect(urlToRedirectTo);
And then in the receiving Controller:
String jspContent = session.getAttribute("jspContentFromRedirect");
if(jspContent != null){
model.addAttribute("jspContent", jspContent);
session.setAttribute("jspContentFromRedirect", null);
}
Something like this