Autolink.

This commit is contained in:
Rico Sta. Cruz 2014-06-09 13:30:52 +08:00
parent 1122be30cd
commit 0524caea00
5 changed files with 32 additions and 9 deletions

View File

@ -1,4 +1,5 @@
<script src="assets/highlight.min.js"></script> <script src="assets/highlight.min.js"></script>
<script src="assets/script.js"></script>
<script> <script>
hljs.configure({classPrefix: ''}); hljs.configure({classPrefix: ''});
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();

17
assets/script.js Normal file
View File

@ -0,0 +1,17 @@
(function () {
var tags = document.querySelectorAll('h1,h2,h3,h4,h5,h6,li,p,span');
for (var i=0, len=tags.length; i<len; i++) {
var tag = tags[i];
if ((~tag.innerHTML.indexOf('>') ||
(!tag.innerHTML.match(/https?:\/\//))))
continue;
tag.innerHTML = tag.innerHTML.replace(/https?:\/\/[^ ]*/g, function (url) {
url = url.replace(/[\.\),!]*$/, '');
var label = url;
label = label.replace(/^https?:\/\//, '')
.replace(/\/$/, '');
return "<a href='"+url+"'>"+label+"</a>";
});
}
})();

View File

@ -3,8 +3,6 @@ title: Jasmine
layout: default layout: default
--- ---
[Jasmine](http://pivotal.github.com/jasmine/).
describe("A suite", function() { describe("A suite", function() {
it("contains spec with an expectation", function() { it("contains spec with an expectation", function() {
expect(true).toBe(true); expect(true).toBe(true);
@ -133,3 +131,7 @@ Jasmine jQuery
$('#some_element').click(); $('#some_element').click();
expect('click').toHaveBeenPreventedOn($('#some_element')); expect('click').toHaveBeenPreventedOn($('#some_element'));
expect('click').toHaveBeenTriggeredOn($('#some_element')); expect('click').toHaveBeenTriggeredOn($('#some_element'));
### Reference
* http://pivotal.github.com/jasmine/

View File

@ -1,6 +1,6 @@
--- ---
title: Mocha.js title: Mocha.js
layout: Default layout: default
--- ---
### BDD ### BDD
@ -34,3 +34,8 @@ layout: Default
foo.should.have.length(3); foo.should.have.length(3);
tea.should.have.property('flavors').with.length(3); tea.should.have.property('flavors').with.length(3);
### See also
* [Chai](chai.html)
* [Sinon](sinon.html)
* [Sinon Chai](sinon-chai.html)

View File

@ -3,14 +3,12 @@ title: Rails features
layout: default layout: default
--- ---
### Caching ### [Page caching](https://github.com/rails/actionpack-page_caching)
https://github.com/rails/actionpack-page_caching
class WeblogController < ActionController::Base class WeblogController < ActionController::Base
caches_page :show, :new caches_page :show, :new
end end
This will generate cache files such as weblog/show/5.html and weblog/new.html, This will generate cache files such as `weblog/show/5.html` and
which match the URLs used that would normally trigger dynamic page `weblog/new.html`, which match the URLs used that would normally trigger dynamic
generation page generation