android HTML template as resource - html

is there any way to have an html file (i.e. an html template) be a resource in android? I'd like to reference it in a similar way that i store strings in the res/values/strings.xml. However, when i do this, it appears the HTML is not getting rendered correctly when i use myTextView.setText(Html.fromHtml(MessageFormat
.format(getResources().getString(R.string.myHtmlFile), ...)

You can place raw HTML or other format files in /res/raw or /assets directory of your project. You can access the first with this method, and the second with this.

Related

How to create a link to a html file using the Meteor local server?

Currently, I have an html file which has a basic layout of a login page which has an option for new users to sign up if they're not a member.
I have the following line inside of my html :
Join Us!
What I want to have happen is load up a new HTML page which will be a modal (using twitter bootstrap) that will ask the user to input the correct data to create a login/pass combination.
But this isn't working. It keeps doing the following (doesn't do anything) :
http://localhost:3000/register.html
I'm a little confused whether my HTML is wrong or MeteorJS requires some sort of specific way to do something like this.
You can use a relative url: Example: register.html only
If your file is into the same project, you don't need to put him an url absolute.
Put your register.html file in your project's /public directory and you will be able to access it via /register.html. However that page will run outside your Meteor app and won't have any Meteor functionality per se.
The /public folder maps to / and is normally used for images and other client-side assets. It's common to map /public/images to /images for example.

Including images in a Genshi/Trac template

I am trying to include some images in a Genshi template for my Trac plugin, but it always shows only the alternative text because it cannot find the images.
I have the following (X)HTML code:
<div>
<img src="file://c:/path/to/image.png" alt="asdf" />
</div>
When I use this code with a simple html file and open it in the browser, the image is displayed correctly, which means that both the path and syntax are correct.
But when I insert the code snippet into a Genshi template and use it within Trac, the image cannot be found. However, when I look at the HTML source code in the web browser and copy the URLs into a new browser tab, it is again displayed correctly. This means that only the server cannot find the image.
The images are in a directory inside the python-egg file, and the path points directly to the directory created by Trac, which also contains my CSS and HTML files, both of which are loaded correctly. The images are correctly referenced in the setup script which creates the egg.
How do I have to reference images in (X)HTML documents when using them with a server?
Is there a special way to include images in Genshi documents? (I haven't found one.)
Thanks to the comment of RjOllos and this site I was able to fix it by trying all of the URL types. Although it says for a plugin to be /chrome/<pluginname>, it was actually just /chrome that worked. See the edit below! So the full URL is then <ip>:<port>/chrome/path/to/image.png.
EDIT: I discovered I actually used the /chrome/pluginname version, just that I did not use the name of my plugin as "pluginname". See my comment below. It seems like /chrome/pluginname should actually be /chrome/htdocsnameor something like that, in case you use a different name rather than the plugin name when implementing the ITemplateProvider. In my case I called it images, which was the same name as the folder. END OF EDIT
Another mistake I made was forgetting the initial slash (chrome/path/to/image.png), which caused Trac to assemble the URL to <ip>:<port>/<current page>/chrome/path/to/image.png.

Using data from XML file and placing it in an already made html page

I'm very new to using xml, but I was wondering if there was a way to have an html file, that calls from a separate xml file for information and displays it in the html file.
Basically I already have a specific flyer or product html file, and I want to call the contents of each product( name, description, price, etc) from a separate xml file and generate it in the already made html file. I see a lot of examples about an xml file generating new html files, but that's not what I need. All i need is for the xml file's information to be displayed on the html, and all the styles on the html file stay effect through css made for that html file.
Can anyone give me some help or point me to the right direction?
thanks!
Go for AJAX
Some Links to get you started:
Read data from XML and load it through AJAX
PHP has got the support for reading XML Content :
AJAX-PHP: http://www.w3schools.com/ajax/ajax_aspphp.asp
http://php.net/xml

Adobe CQ - fetch HTML content from .jsp node

Have .jsp file under /components
path looks like: http://localhost:4502/apps/project-name/components/my-component/one.jsp
Is it possible get HTML content of this one.jsp by url without creating content node?
something like:
http://localhost:4502/apps/project-name/components/my-component/one.HTML
the .html content is needed for further rendering.
As far as i know, you cannot get the html content from the JSP directly by providing the path to the jsp file. It displays the content in the JSP as is without compiling.
One possible way is to create an nt:unstructured node with the sling:resourceType property set to the path of the jsp (something like below)
test: {
sling:resourceType: "/apps/geometrixx/components/title/one.jsp",
jcr:primaryType: "nt:unstructured"
}
And you can provide the path to the test node to get the html rendered by the jsp.
/apps/geometrixx/components/title/test
Your question is a bit vague but as far as i get it, you want to retrieve the html for the whole page which can be done by reading the input stream from a URL using java.net.URL utility.
May be you can also place an iframe inside your other jsp to get the contents.
You could always use a traditional .html file instead of a .jsp, but (perhaps obviously) you will lose all the server side capabilities afforded by JSP.
It is also worth noting that anonymous access is typically denied to /apps for security reasons, so this .html file would not be reachable on a publish instance with OOTB permissions.

iphone uiwebview download complete page with CSS and Images

In my app there's a uiwebview that loads a URL.
I am using the following line to save the HTML of the page loaded locally to be able to view it offline:
NSString* html=[webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('html')[0].innerHTML"]
The problem is that only the HTML of the document gets saved. I want to save also the images and the CSS along with the HTML so that the user see the page as if they are online.
Just like "save web page complete" or something like that, that we're used to in the browsers.
There is no easy way. Regex the HTML using RegexKitLite (http://regexkit.sourceforge.net/RegexKitLite/index.html) and snag all the urls to .jpg,.gif,.png, and .css and .js and whatever all else you need.
alternately, call:
NSString* imgUrls=[webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('img')"]
or something like that, I'm no javascript whizz... and then deal with whatever all that returns ;)
Sorry. It's a pain in the rearheinie.
edit:
Save all the img's on the iphone, also save the html file. When you want to reload the page, load the html from a file into a string, and then use
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
to load the HTML string. baseURL is used to specify the directory or site the webview will imagine the html string you hand it is located. All URLS will be relative to that.
Note, of course that this will not work very well for absolute URLs, only for relative ones. So this, in your html file, will monkey things up:
<img src="http://google.com/f/r/i/g/img.gif">
while this would be ok:
<img src="f/r/i/g/img.gif">
Again, this whole solution is mucky.
You might look into a pre-existing open source recursive html spider. I think wget does what you want, but I doubt it can be compiled for iPhone without a -lot- of hassle.
I didn't have time to check, but ASIWebPageRequest seams very promising. It states it can "Store a complete web page in a single string, or with each external resource in a separate file referenced from the page"
ASIWebPageRequest1
I will be using it on one of my projects, and then update thread.
Gonso