Skip to content

Commit 31ee8ea

Browse files
committed
Minor changes
1 parent 46831bf commit 31ee8ea

4 files changed

Lines changed: 24 additions & 14 deletions

File tree

htmlpreview.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ var HTMLPreview = {
5656
&& data.query
5757
&& data.query.results
5858
&& data.query.results.resources
59-
&& data.query.results.resources.content) {
60-
this.content = data.query.results.resources.content.replace(/<head>/i,'<head><base href="'+this.folder()+'">').replace(/<\/body>/i,'<script src="http://' + location.hostname + '/htmlpreview.js"></script><script>HTMLPreview.replaceScripts();</script></body>'); //Add <base> just after <head> and inject <script> just before </body>
59+
&& data.query.results.resources.content
60+
&& data.query.results.resources.status == 200) {
61+
this.content = data.query.results.resources.content.replace(/<head>/i,'<head><base href="'+this.folder()+'">').replace(/<\/body>/i,'<script src="http://' + location.hostname + '/htmlpreview.min.js"></script><script>HTMLPreview.replaceScripts();</script></body>'); //Add <base> just after <head> and inject <script> just before </body>
6162
setTimeout(function() {
6263
document.open();
6364
document.write(HTMLPreview.content);
@@ -78,7 +79,8 @@ var HTMLPreview = {
7879
&& data.query
7980
&& data.query.results
8081
&& data.query.results.resources
81-
&& data.query.results.resources.content) {
82+
&& data.query.results.resources.content
83+
&& data.query.results.resources.status == 200) {
8284
document.write('<style>'+data.query.results.resources.content+'</style>');
8385
}
8486
},
@@ -88,7 +90,8 @@ var HTMLPreview = {
8890
&& data.query
8991
&& data.query.results
9092
&& data.query.results.resources
91-
&& data.query.results.resources.content) {
93+
&& data.query.results.resources.content
94+
&& data.query.results.resources.status == 200) {
9295
document.write('<scr'+'ipt>'+data.query.results.resources.content+'</scr'+'ipt>');
9396
}
9497
},

htmlpreview.min.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
<h1>GitHub HTML Preview</h1>
3535
<p>Enter the HTML file to preview: <input type="url" id="file" value="" placeholder="e.g. https://github.com/user/repo/blob/master/index.html" size="70"> <input type="submit" value="&raquo;"></p>
3636
<p>or prepend to the URL: <strong>http://htmlpreview.github.com/?</strong>https://github.com/twitter/bootstrap/blob/master/docs/index.html</p>
37-
<p id="footer">Developed by <a href="https://github.com/niutech">niu tech</a> | <a href="https://github.com/htmlpreview/htmlpreview.github.com">Contribute on GitHub</a></p>
37+
<p id="footer">Developed by <a href="https://github.com/niutech">niu tech</a> | Contribute on <a href="https://github.com/htmlpreview/htmlpreview.github.com">GitHub</a></p>
3838
</form>
39-
<script src="/htmlpreview.js"></script>
39+
<script src="/htmlpreview.min.js"></script>
4040
<script>HTMLPreview.init();</script>
4141
</body>
4242
</html>

readme.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
Many GitHub repositories doesn't use GitHub Pages to host their HTML files. GitHub HTML Preview
2-
allows you to render those files without cloning or downloading whole repositories.
1+
Many GitHub repositories doesn't use GitHub Pages to host their HTML files. GitHub HTML
2+
Preview allows you to render those files without cloning or downloading whole repositories.
33

4-
If you try to open raw versions of any HTML, CSS or JS files in a web browser directly from GitHub,
5-
all you will see are sources. GitHub forces them to use the "text/plain" content-type. This script
6-
overrides it by using Yahoo! Query Language.
4+
If you try to open raw versions of any HTML, CSS or JS files in a web browser directly from
5+
GitHub, all you will see are sources. GitHub forces them to use the "text/plain" content-type.
6+
This script overrides it by using Yahoo! Query Language.
77

88
To use it, just prepend this to the URL of any HTML file: http://htmlpreview.github.com/?
99

10-
E.g.: http://htmlpreview.github.com/?https://github.com/twitter/bootstrap/blob/master/docs/index.html
10+
E.g.:
11+
http://htmlpreview.github.com/?https://github.com/twitter/bootstrap/blob/master/docs/index.html
12+
http://htmlpreview.github.com/?https://github.com/documentcloud/backbone/blob/master/examples/todos/index.html
1113

12-
GitHub HTML Preview is tested under Google Chrome and Mozilla Firefox, and it should work with any
13-
websites, not only GitHub.
14+
GitHub HTML Preview is tested under Google Chrome, Apple Safari and Mozilla Firefox, and it
15+
should work with any websites, not only GitHub.

0 commit comments

Comments
 (0)