From ecedceb57e1b016efd1d4630622c4f7650604d77 Mon Sep 17 00:00:00 2001 From: Ben Tranter Date: Thu, 5 Sep 2019 16:54:52 -0400 Subject: [PATCH] Release v0.2.0 --- docs/Turbolinks.html | 6 +++--- docs/Turbolinks/Handler.html | 4 ++-- docs/index.json | 2 +- docs/search-index.js | 2 +- shard.yml | 2 +- src/turbolinks/version.cr | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/Turbolinks.html b/docs/Turbolinks.html index 0e6ffc5..4744df3 100644 --- a/docs/Turbolinks.html +++ b/docs/Turbolinks.html @@ -89,14 +89,14 @@

Overview

Defined in:

- + turbolinks/version.cr
- + turbolinks.cr @@ -111,7 +111,7 @@

Constant Summary

- VERSION = "0.1.1" + VERSION = "0.2.0"
diff --git a/docs/Turbolinks/Handler.html b/docs/Turbolinks/Handler.html index 3cd4ffd..e52129f 100644 --- a/docs/Turbolinks/Handler.html +++ b/docs/Turbolinks/Handler.html @@ -109,7 +109,7 @@

Included Modules

Defined in:

- + turbolinks.cr @@ -196,7 +196,7 @@

Instance Method Detail


- [View source] + [View source]
diff --git a/docs/index.json b/docs/index.json index 6f25e20..1f88d32 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"github.com/bentranter/turbolinks","body":"# Turbolinks\n\n[![Build Status](https://travis-ci.org/bentranter/turbolinks.svg?branch=master)](https://travis-ci.org/bentranter/turbolinks) [![License](https://img.shields.io/github/license/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/releases)\n\nCrystal engine for Turbolinks integration. Extends `HTTP::Handler`, so you can use it as middleware in any web application. Don't forget to grab the [frontend code for Turbolinks](https://github.com/turbolinks/turbolinks).\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n turbolinks:\n github: bentranter/turbolinks\n```\n\n## Usage\n\nTurbolinks extends `HTTP::Handler`, so it can be used as HTTP middleware. You can use it with the standard library like so:\n\n```crystal\nrequire \"http/server\"\nrequire \"turbolinks\"\n\nHTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n]).listen\n```\n\nor with a framework that supports standard HTTP middleware. For example, you can use Turbolinks with Kemal like so:\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\n# Calling `add_handler` is Kemal's way of registering HTTP middleware.\nadd_handler Turbolinks::Handler.new\n\nget \"/\"\n \"Served by Turbolinks!\"\nend\n\nKemal.run\n```\n\n## A Note About Security\n\nA common pattern if you're coming from the Rails world (and using something like [rails-ujs](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts)) a common approach is to handle a `POST` request, and then redirect to another route. Turbolinks handles this case by intercepting the redirection after the `POST` request executes, and then responding with a JavaScript snippet to execute `Turbolinks.visit(\"#{location}\")` for the location to redirect to.\n\nWhile this is typically safe, if your handler allows the user to input this `location`, you open yourself up to JavaScript injection. Lets look at two examples where a user is leaving a comment, submitted through a form `post` request.\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\nadd_handler Turbolinks::Handler.new\n\n# Unsafe approach!\npost \"/unsafe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n new_comment(title, comment)\n\n # This is dangerous because the value of `title` here could be anything --\n # including malicious JavaScript. Since the frontend will excute JavaScript\n # containing the value of this redirect here, any malicious JavaScript will\n # execute.\n env.redirect \"/comments/#{title}\"\nend\n\n# Safe approach.\npost \"/safe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n comment_id = new_comment(title, comment)\n\n # This is safe because there's no way for the user submitted `title` or\n # `comment` to be available in the returned JavaScript -- you generate an\n # ID, and redirect to that route.\n env.redirect \"/comments/#{comment_id}\"\nend\n\nKemal.run\n```\n\nIf you _must_ do something like the unsafe approach, you'll need to sanitize the input yourself.\n\n## A Note For Non `rails-ujs` Users\n\nIn order for form submissions _not_ to trigger a full page reload, you'll need to ensure that those submissions are submitted as AJAX requests. While a library like [Rails-UJS](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts) or [JQuery-UJS](https://github.com/rails/jquery-ujs) would handle this for you, it's straightforward to implement this yourself. The following JavaScript snippet adds bare-minimum support for AJAX form submissions that work with Turbolinks, but I encourage to look at what `rails-ujs` does as well.\n\n```js\n(function() {\n \"use strict\";\n /*\n * For Google Analytics, you need this:\n * \n * \n * ...the rest of the body here...\n * \n * See https://coderwall.com/p/ypzfdw/faster-page-loads-with-turbolinks for\n * more info.\n */\n\n /*\n * By default, Turbolinks submits forms normally. While this may feel\n * frustrating as a consumer of the library, it makes sense:\n * - No specialized logic on the backend\n * - Cache is purged since the page refreshed.\n * However, that's not always what you want. By using the functionality\n * below, forms are submitted via AJAX, as recommended in the Turbolinks\n * documentation.\n */\n document.addEventListener(\"DOMContentLoaded\", function() {\n /**\n * submit sends an HTTP request via XHR.\n * @param {*Object} formEl - the form element to submit via XHR.\n */\n function submit(formEl) {\n var xhr = new XMLHttpRequest();\n xhr.open(formEl.method, formEl.action, true);\n\n /* See\n * https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee\n * for a more in-depth usage.\n */\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4 && xhr.status === 200) {\n var script = document.createElement(\"script\");\n script.innerText = xhr.responseText;\n document.head.appendChild(script).parentNode.removeChild(script);\n }\n }\n /* Set relevant headers that some backends check for */\n xhr.setRequestHeader(\"Turbolinks-Referrer\", window.location.href);\n xhr.setRequestHeader(\"X-Requested-With\", \"xhr\");\n xhr.send(new FormData(formEl));\n return false;\n }\n\n /* Intercept **any** submit event to submit via XHR instead. */\n document.addEventListener(\"submit\", function(e) {\n e.preventDefault();\n if (e.srcElement) {\n submit(e.srcElement);\n }\n });\n });\n})();\n```\n\n## Development\n\nTurbolinks follows the typical Crystal project structure, so cloning the repo and making changes is all you need to do. However, you're encouraged to run this backend alongside the Turbolinks frontend to make sure it works as expected, especially when compared to the Rails backend. The Turbolinks frontend is available at [github.com/turbolinks/turbolinks](https://github.com/turbolinks/turbolinks), and the Rails gem is available at [github.com/turbolinks/turbolinks-rails](https://github.com/turbolinks/turbolinks-rails).\n\n## Contributing\n\n1. Fork it ( https://github.com/[your-github-name]/turbolinks/fork )\n1. Create your feature branch (git checkout -b my-new-feature)\n1. Make sure the tests pass, adding any necessary new tests\n1. Format your code with `crystal tool format`\n1. Commit your changes (git commit -am 'Add some feature')\n1. Push to the branch (git push origin my-new-feature)\n1. Create a new Pull Request\n\n## Contributors\n\n- [bentranter](https://github.com/bentranter) Ben Tranter - creator, maintainer\n\n## License\n\nThe MIT License (MIT). Copyright (c) 2017-2019 Ben Tranter. See the [LICENSE](/LICENSE) for more info.\n","program":{"html_id":"github.com/bentranter/turbolinks/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/bentranter/turbolinks","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks","path":"Turbolinks.html","kind":"module","full_name":"Turbolinks","name":"Turbolinks","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"turbolinks/version.cr","line_number":1,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks/version.cr"},{"filename":"turbolinks.cr","line_number":7,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.1\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"Turbolinks a module that provides HTTP middleware to be used with\nTurbolinks powered frontends. It handles form submission, and redirection.","summary":"

Turbolinks a module that provides HTTP middleware to be used with Turbolinks powered frontends.

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks/Handler","path":"Turbolinks/Handler.html","kind":"class","full_name":"Turbolinks::Handler","name":"Handler","abstract":false,"superclass":{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"},{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/bentranter/turbolinks/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"turbolinks.cr","line_number":22,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/bentranter/turbolinks/Turbolinks","kind":"module","full_name":"Turbolinks","name":"Turbolinks"},"doc":"A handler that handles form submission and redirection for Turbolinks\nenabled frontends. It does nothing if the frontend is not using\nTurbolinks, so it can safely be used as HTTP middleware for any\napplication.\n\nUse like you would use any HTTP middleware:\n\n require \"http/server\"\n require \"turbolinks\"\n\n HTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n ]).listen\n","summary":"

A handler that handles form submission and redirection for Turbolinks enabled frontends.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"call(context:HTTP::Server::Context)-instance-method","html_id":"call(context:HTTP::Server::Context)-instance-method","name":"call","doc":"Executes the middleware. This function is called by the HTTP server\nafter you've registered it as middleware, so you won't need to use this\nfunction directly.","summary":"

Executes the middleware.

","abstract":false,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"args_string":"(context : HTTP::Server::Context)","source_link":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr#L30","def":{"name":"call","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if context.request.headers.get?(\"Turbolinks-Referrer\")\nelse\n return call_next(context)\nend\nif context.request.method == \"POST\"\n call_next(context)\n post(context)\n return\nend\ncheck_redirect(context)\ncall_next(context)\nget(context)\n"}}],"macros":[],"types":[]}]}]}} \ No newline at end of file +{"repository_name":"github.com/bentranter/turbolinks","body":"# Turbolinks\n\n[![Build Status](https://travis-ci.org/bentranter/turbolinks.svg?branch=master)](https://travis-ci.org/bentranter/turbolinks) [![License](https://img.shields.io/github/license/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/releases)\n\nCrystal engine for Turbolinks integration. Extends `HTTP::Handler`, so you can use it as middleware in any web application. Don't forget to grab the [frontend code for Turbolinks](https://github.com/turbolinks/turbolinks).\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n turbolinks:\n github: bentranter/turbolinks\n```\n\n## Usage\n\nTurbolinks extends `HTTP::Handler`, so it can be used as HTTP middleware. You can use it with the standard library like so:\n\n```crystal\nrequire \"http/server\"\nrequire \"turbolinks\"\n\nHTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n]).listen\n```\n\nor with a framework that supports standard HTTP middleware. For example, you can use Turbolinks with Kemal like so:\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\n# Calling `add_handler` is Kemal's way of registering HTTP middleware.\nadd_handler Turbolinks::Handler.new\n\nget \"/\"\n \"Served by Turbolinks!\"\nend\n\nKemal.run\n```\n\n## A Note About Security\n\nA common pattern if you're coming from the Rails world (and using something like [rails-ujs](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts)) a common approach is to handle a `POST` request, and then redirect to another route. Turbolinks handles this case by intercepting the redirection after the `POST` request executes, and then responding with a JavaScript snippet to execute `Turbolinks.visit(\"#{location}\")` for the location to redirect to.\n\nWhile this is typically safe, if your handler allows the user to input this `location`, you open yourself up to JavaScript injection. Lets look at two examples where a user is leaving a comment, submitted through a form `post` request.\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\nadd_handler Turbolinks::Handler.new\n\n# Unsafe approach!\npost \"/unsafe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n new_comment(title, comment)\n\n # This is dangerous because the value of `title` here could be anything --\n # including malicious JavaScript. Since the frontend will excute JavaScript\n # containing the value of this redirect here, any malicious JavaScript will\n # execute.\n env.redirect \"/comments/#{title}\"\nend\n\n# Safe approach.\npost \"/safe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n comment_id = new_comment(title, comment)\n\n # This is safe because there's no way for the user submitted `title` or\n # `comment` to be available in the returned JavaScript -- you generate an\n # ID, and redirect to that route.\n env.redirect \"/comments/#{comment_id}\"\nend\n\nKemal.run\n```\n\nIf you _must_ do something like the unsafe approach, you'll need to sanitize the input yourself.\n\n## A Note For Non `rails-ujs` Users\n\nIn order for form submissions _not_ to trigger a full page reload, you'll need to ensure that those submissions are submitted as AJAX requests. While a library like [Rails-UJS](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts) or [JQuery-UJS](https://github.com/rails/jquery-ujs) would handle this for you, it's straightforward to implement this yourself. The following JavaScript snippet adds bare-minimum support for AJAX form submissions that work with Turbolinks, but I encourage to look at what `rails-ujs` does as well.\n\n```js\n(function() {\n \"use strict\";\n /*\n * For Google Analytics, you need this:\n * \n * \n * ...the rest of the body here...\n * \n * See https://coderwall.com/p/ypzfdw/faster-page-loads-with-turbolinks for\n * more info.\n */\n\n /*\n * By default, Turbolinks submits forms normally. While this may feel\n * frustrating as a consumer of the library, it makes sense:\n * - No specialized logic on the backend\n * - Cache is purged since the page refreshed.\n * However, that's not always what you want. By using the functionality\n * below, forms are submitted via AJAX, as recommended in the Turbolinks\n * documentation.\n */\n document.addEventListener(\"DOMContentLoaded\", function() {\n /**\n * submit sends an HTTP request via XHR.\n * @param {*Object} formEl - the form element to submit via XHR.\n */\n function submit(formEl) {\n var xhr = new XMLHttpRequest();\n xhr.open(formEl.method, formEl.action, true);\n\n /* See\n * https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee\n * for a more in-depth usage.\n */\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4 && xhr.status === 200) {\n var script = document.createElement(\"script\");\n script.innerText = xhr.responseText;\n document.head.appendChild(script).parentNode.removeChild(script);\n }\n }\n /* Set relevant headers that some backends check for */\n xhr.setRequestHeader(\"Turbolinks-Referrer\", window.location.href);\n xhr.setRequestHeader(\"X-Requested-With\", \"xhr\");\n xhr.send(new FormData(formEl));\n return false;\n }\n\n /* Intercept **any** submit event to submit via XHR instead. */\n document.addEventListener(\"submit\", function(e) {\n e.preventDefault();\n if (e.srcElement) {\n submit(e.srcElement);\n }\n });\n });\n})();\n```\n\n## Development\n\nTurbolinks follows the typical Crystal project structure, so cloning the repo and making changes is all you need to do. However, you're encouraged to run this backend alongside the Turbolinks frontend to make sure it works as expected, especially when compared to the Rails backend. The Turbolinks frontend is available at [github.com/turbolinks/turbolinks](https://github.com/turbolinks/turbolinks), and the Rails gem is available at [github.com/turbolinks/turbolinks-rails](https://github.com/turbolinks/turbolinks-rails).\n\n## Contributing\n\n1. Fork it ( https://github.com/[your-github-name]/turbolinks/fork )\n1. Create your feature branch (git checkout -b my-new-feature)\n1. Make sure the tests pass, adding any necessary new tests\n1. Format your code with `crystal tool format`\n1. Commit your changes (git commit -am 'Add some feature')\n1. Push to the branch (git push origin my-new-feature)\n1. Create a new Pull Request\n\n## Contributors\n\n- [bentranter](https://github.com/bentranter) Ben Tranter - creator, maintainer\n\n## License\n\nThe MIT License (MIT). Copyright (c) 2017-2019 Ben Tranter. See the [LICENSE](/LICENSE) for more info.\n","program":{"html_id":"github.com/bentranter/turbolinks/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/bentranter/turbolinks","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks","path":"Turbolinks.html","kind":"module","full_name":"Turbolinks","name":"Turbolinks","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"turbolinks/version.cr","line_number":1,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks/version.cr"},{"filename":"turbolinks.cr","line_number":7,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.2.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"Turbolinks a module that provides HTTP middleware to be used with\nTurbolinks powered frontends. It handles form submission, and redirection.","summary":"

Turbolinks a module that provides HTTP middleware to be used with Turbolinks powered frontends.

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks/Handler","path":"Turbolinks/Handler.html","kind":"class","full_name":"Turbolinks::Handler","name":"Handler","abstract":false,"superclass":{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"},{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/bentranter/turbolinks/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"turbolinks.cr","line_number":22,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/bentranter/turbolinks/Turbolinks","kind":"module","full_name":"Turbolinks","name":"Turbolinks"},"doc":"A handler that handles form submission and redirection for Turbolinks\nenabled frontends. It does nothing if the frontend is not using\nTurbolinks, so it can safely be used as HTTP middleware for any\napplication.\n\nUse like you would use any HTTP middleware:\n\n require \"http/server\"\n require \"turbolinks\"\n\n HTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n ]).listen\n","summary":"

A handler that handles form submission and redirection for Turbolinks enabled frontends.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"call(context:HTTP::Server::Context)-instance-method","html_id":"call(context:HTTP::Server::Context)-instance-method","name":"call","doc":"Executes the middleware. This function is called by the HTTP server\nafter you've registered it as middleware, so you won't need to use this\nfunction directly.","summary":"

Executes the middleware.

","abstract":false,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"args_string":"(context : HTTP::Server::Context)","source_link":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr#L30","def":{"name":"call","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if context.request.headers.get?(\"Turbolinks-Referrer\")\nelse\n return call_next(context)\nend\nif context.request.method == \"POST\"\n call_next(context)\n post(context)\n return\nend\ncheck_redirect(context)\ncall_next(context)\nget(context)\n"}}],"macros":[],"types":[]}]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index f4087dd..5ac6a45 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"github.com/bentranter/turbolinks","body":"# Turbolinks\n\n[![Build Status](https://travis-ci.org/bentranter/turbolinks.svg?branch=master)](https://travis-ci.org/bentranter/turbolinks) [![License](https://img.shields.io/github/license/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/releases)\n\nCrystal engine for Turbolinks integration. Extends `HTTP::Handler`, so you can use it as middleware in any web application. Don't forget to grab the [frontend code for Turbolinks](https://github.com/turbolinks/turbolinks).\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n turbolinks:\n github: bentranter/turbolinks\n```\n\n## Usage\n\nTurbolinks extends `HTTP::Handler`, so it can be used as HTTP middleware. You can use it with the standard library like so:\n\n```crystal\nrequire \"http/server\"\nrequire \"turbolinks\"\n\nHTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n]).listen\n```\n\nor with a framework that supports standard HTTP middleware. For example, you can use Turbolinks with Kemal like so:\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\n# Calling `add_handler` is Kemal's way of registering HTTP middleware.\nadd_handler Turbolinks::Handler.new\n\nget \"/\"\n \"Served by Turbolinks!\"\nend\n\nKemal.run\n```\n\n## A Note About Security\n\nA common pattern if you're coming from the Rails world (and using something like [rails-ujs](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts)) a common approach is to handle a `POST` request, and then redirect to another route. Turbolinks handles this case by intercepting the redirection after the `POST` request executes, and then responding with a JavaScript snippet to execute `Turbolinks.visit(\"#{location}\")` for the location to redirect to.\n\nWhile this is typically safe, if your handler allows the user to input this `location`, you open yourself up to JavaScript injection. Lets look at two examples where a user is leaving a comment, submitted through a form `post` request.\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\nadd_handler Turbolinks::Handler.new\n\n# Unsafe approach!\npost \"/unsafe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n new_comment(title, comment)\n\n # This is dangerous because the value of `title` here could be anything --\n # including malicious JavaScript. Since the frontend will excute JavaScript\n # containing the value of this redirect here, any malicious JavaScript will\n # execute.\n env.redirect \"/comments/#{title}\"\nend\n\n# Safe approach.\npost \"/safe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n comment_id = new_comment(title, comment)\n\n # This is safe because there's no way for the user submitted `title` or\n # `comment` to be available in the returned JavaScript -- you generate an\n # ID, and redirect to that route.\n env.redirect \"/comments/#{comment_id}\"\nend\n\nKemal.run\n```\n\nIf you _must_ do something like the unsafe approach, you'll need to sanitize the input yourself.\n\n## A Note For Non `rails-ujs` Users\n\nIn order for form submissions _not_ to trigger a full page reload, you'll need to ensure that those submissions are submitted as AJAX requests. While a library like [Rails-UJS](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts) or [JQuery-UJS](https://github.com/rails/jquery-ujs) would handle this for you, it's straightforward to implement this yourself. The following JavaScript snippet adds bare-minimum support for AJAX form submissions that work with Turbolinks, but I encourage to look at what `rails-ujs` does as well.\n\n```js\n(function() {\n \"use strict\";\n /*\n * For Google Analytics, you need this:\n * \n * \n * ...the rest of the body here...\n * \n * See https://coderwall.com/p/ypzfdw/faster-page-loads-with-turbolinks for\n * more info.\n */\n\n /*\n * By default, Turbolinks submits forms normally. While this may feel\n * frustrating as a consumer of the library, it makes sense:\n * - No specialized logic on the backend\n * - Cache is purged since the page refreshed.\n * However, that's not always what you want. By using the functionality\n * below, forms are submitted via AJAX, as recommended in the Turbolinks\n * documentation.\n */\n document.addEventListener(\"DOMContentLoaded\", function() {\n /**\n * submit sends an HTTP request via XHR.\n * @param {*Object} formEl - the form element to submit via XHR.\n */\n function submit(formEl) {\n var xhr = new XMLHttpRequest();\n xhr.open(formEl.method, formEl.action, true);\n\n /* See\n * https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee\n * for a more in-depth usage.\n */\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4 && xhr.status === 200) {\n var script = document.createElement(\"script\");\n script.innerText = xhr.responseText;\n document.head.appendChild(script).parentNode.removeChild(script);\n }\n }\n /* Set relevant headers that some backends check for */\n xhr.setRequestHeader(\"Turbolinks-Referrer\", window.location.href);\n xhr.setRequestHeader(\"X-Requested-With\", \"xhr\");\n xhr.send(new FormData(formEl));\n return false;\n }\n\n /* Intercept **any** submit event to submit via XHR instead. */\n document.addEventListener(\"submit\", function(e) {\n e.preventDefault();\n if (e.srcElement) {\n submit(e.srcElement);\n }\n });\n });\n})();\n```\n\n## Development\n\nTurbolinks follows the typical Crystal project structure, so cloning the repo and making changes is all you need to do. However, you're encouraged to run this backend alongside the Turbolinks frontend to make sure it works as expected, especially when compared to the Rails backend. The Turbolinks frontend is available at [github.com/turbolinks/turbolinks](https://github.com/turbolinks/turbolinks), and the Rails gem is available at [github.com/turbolinks/turbolinks-rails](https://github.com/turbolinks/turbolinks-rails).\n\n## Contributing\n\n1. Fork it ( https://github.com/[your-github-name]/turbolinks/fork )\n1. Create your feature branch (git checkout -b my-new-feature)\n1. Make sure the tests pass, adding any necessary new tests\n1. Format your code with `crystal tool format`\n1. Commit your changes (git commit -am 'Add some feature')\n1. Push to the branch (git push origin my-new-feature)\n1. Create a new Pull Request\n\n## Contributors\n\n- [bentranter](https://github.com/bentranter) Ben Tranter - creator, maintainer\n\n## License\n\nThe MIT License (MIT). Copyright (c) 2017-2019 Ben Tranter. See the [LICENSE](/LICENSE) for more info.\n","program":{"html_id":"github.com/bentranter/turbolinks/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/bentranter/turbolinks","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks","path":"Turbolinks.html","kind":"module","full_name":"Turbolinks","name":"Turbolinks","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"turbolinks/version.cr","line_number":1,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks/version.cr"},{"filename":"turbolinks.cr","line_number":7,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.1\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"Turbolinks a module that provides HTTP middleware to be used with\nTurbolinks powered frontends. It handles form submission, and redirection.","summary":"

Turbolinks a module that provides HTTP middleware to be used with Turbolinks powered frontends.

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks/Handler","path":"Turbolinks/Handler.html","kind":"class","full_name":"Turbolinks::Handler","name":"Handler","abstract":false,"superclass":{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"},{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/bentranter/turbolinks/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"turbolinks.cr","line_number":22,"url":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/bentranter/turbolinks/Turbolinks","kind":"module","full_name":"Turbolinks","name":"Turbolinks"},"doc":"A handler that handles form submission and redirection for Turbolinks\nenabled frontends. It does nothing if the frontend is not using\nTurbolinks, so it can safely be used as HTTP middleware for any\napplication.\n\nUse like you would use any HTTP middleware:\n\n require \"http/server\"\n require \"turbolinks\"\n\n HTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n ]).listen\n","summary":"

A handler that handles form submission and redirection for Turbolinks enabled frontends.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"call(context:HTTP::Server::Context)-instance-method","html_id":"call(context:HTTP::Server::Context)-instance-method","name":"call","doc":"Executes the middleware. This function is called by the HTTP server\nafter you've registered it as middleware, so you won't need to use this\nfunction directly.","summary":"

Executes the middleware.

","abstract":false,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"args_string":"(context : HTTP::Server::Context)","source_link":"https://github.com/bentranter/turbolinks/blob/d80759fb6c2f59a6883e7f9664c1dce83f8f518d/src/turbolinks.cr#L30","def":{"name":"call","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if context.request.headers.get?(\"Turbolinks-Referrer\")\nelse\n return call_next(context)\nend\nif context.request.method == \"POST\"\n call_next(context)\n post(context)\n return\nend\ncheck_redirect(context)\ncall_next(context)\nget(context)\n"}}],"macros":[],"types":[]}]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"github.com/bentranter/turbolinks","body":"# Turbolinks\n\n[![Build Status](https://travis-ci.org/bentranter/turbolinks.svg?branch=master)](https://travis-ci.org/bentranter/turbolinks) [![License](https://img.shields.io/github/license/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bentranter/turbolinks.svg)](https://github.com/bentranter/turbolinks/releases)\n\nCrystal engine for Turbolinks integration. Extends `HTTP::Handler`, so you can use it as middleware in any web application. Don't forget to grab the [frontend code for Turbolinks](https://github.com/turbolinks/turbolinks).\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n turbolinks:\n github: bentranter/turbolinks\n```\n\n## Usage\n\nTurbolinks extends `HTTP::Handler`, so it can be used as HTTP middleware. You can use it with the standard library like so:\n\n```crystal\nrequire \"http/server\"\nrequire \"turbolinks\"\n\nHTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n]).listen\n```\n\nor with a framework that supports standard HTTP middleware. For example, you can use Turbolinks with Kemal like so:\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\n# Calling `add_handler` is Kemal's way of registering HTTP middleware.\nadd_handler Turbolinks::Handler.new\n\nget \"/\"\n \"Served by Turbolinks!\"\nend\n\nKemal.run\n```\n\n## A Note About Security\n\nA common pattern if you're coming from the Rails world (and using something like [rails-ujs](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts)) a common approach is to handle a `POST` request, and then redirect to another route. Turbolinks handles this case by intercepting the redirection after the `POST` request executes, and then responding with a JavaScript snippet to execute `Turbolinks.visit(\"#{location}\")` for the location to redirect to.\n\nWhile this is typically safe, if your handler allows the user to input this `location`, you open yourself up to JavaScript injection. Lets look at two examples where a user is leaving a comment, submitted through a form `post` request.\n\n```crystal\nrequire \"kemal\"\nrequire \"turbolinks\"\n\nadd_handler Turbolinks::Handler.new\n\n# Unsafe approach!\npost \"/unsafe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n new_comment(title, comment)\n\n # This is dangerous because the value of `title` here could be anything --\n # including malicious JavaScript. Since the frontend will excute JavaScript\n # containing the value of this redirect here, any malicious JavaScript will\n # execute.\n env.redirect \"/comments/#{title}\"\nend\n\n# Safe approach.\npost \"/safe-comment\" do |env|\n title = env.params.body[\"title\"]\n comment = env.params.body[\"comment\"]\n\n # Imagine `new_comment` does something to handle a new commment, for\n # example's sake.\n comment_id = new_comment(title, comment)\n\n # This is safe because there's no way for the user submitted `title` or\n # `comment` to be available in the returned JavaScript -- you generate an\n # ID, and redirect to that route.\n env.redirect \"/comments/#{comment_id}\"\nend\n\nKemal.run\n```\n\nIf you _must_ do something like the unsafe approach, you'll need to sanitize the input yourself.\n\n## A Note For Non `rails-ujs` Users\n\nIn order for form submissions _not_ to trigger a full page reload, you'll need to ensure that those submissions are submitted as AJAX requests. While a library like [Rails-UJS](https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts) or [JQuery-UJS](https://github.com/rails/jquery-ujs) would handle this for you, it's straightforward to implement this yourself. The following JavaScript snippet adds bare-minimum support for AJAX form submissions that work with Turbolinks, but I encourage to look at what `rails-ujs` does as well.\n\n```js\n(function() {\n \"use strict\";\n /*\n * For Google Analytics, you need this:\n * \n * \n * ...the rest of the body here...\n * \n * See https://coderwall.com/p/ypzfdw/faster-page-loads-with-turbolinks for\n * more info.\n */\n\n /*\n * By default, Turbolinks submits forms normally. While this may feel\n * frustrating as a consumer of the library, it makes sense:\n * - No specialized logic on the backend\n * - Cache is purged since the page refreshed.\n * However, that's not always what you want. By using the functionality\n * below, forms are submitted via AJAX, as recommended in the Turbolinks\n * documentation.\n */\n document.addEventListener(\"DOMContentLoaded\", function() {\n /**\n * submit sends an HTTP request via XHR.\n * @param {*Object} formEl - the form element to submit via XHR.\n */\n function submit(formEl) {\n var xhr = new XMLHttpRequest();\n xhr.open(formEl.method, formEl.action, true);\n\n /* See\n * https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee\n * for a more in-depth usage.\n */\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4 && xhr.status === 200) {\n var script = document.createElement(\"script\");\n script.innerText = xhr.responseText;\n document.head.appendChild(script).parentNode.removeChild(script);\n }\n }\n /* Set relevant headers that some backends check for */\n xhr.setRequestHeader(\"Turbolinks-Referrer\", window.location.href);\n xhr.setRequestHeader(\"X-Requested-With\", \"xhr\");\n xhr.send(new FormData(formEl));\n return false;\n }\n\n /* Intercept **any** submit event to submit via XHR instead. */\n document.addEventListener(\"submit\", function(e) {\n e.preventDefault();\n if (e.srcElement) {\n submit(e.srcElement);\n }\n });\n });\n})();\n```\n\n## Development\n\nTurbolinks follows the typical Crystal project structure, so cloning the repo and making changes is all you need to do. However, you're encouraged to run this backend alongside the Turbolinks frontend to make sure it works as expected, especially when compared to the Rails backend. The Turbolinks frontend is available at [github.com/turbolinks/turbolinks](https://github.com/turbolinks/turbolinks), and the Rails gem is available at [github.com/turbolinks/turbolinks-rails](https://github.com/turbolinks/turbolinks-rails).\n\n## Contributing\n\n1. Fork it ( https://github.com/[your-github-name]/turbolinks/fork )\n1. Create your feature branch (git checkout -b my-new-feature)\n1. Make sure the tests pass, adding any necessary new tests\n1. Format your code with `crystal tool format`\n1. Commit your changes (git commit -am 'Add some feature')\n1. Push to the branch (git push origin my-new-feature)\n1. Create a new Pull Request\n\n## Contributors\n\n- [bentranter](https://github.com/bentranter) Ben Tranter - creator, maintainer\n\n## License\n\nThe MIT License (MIT). Copyright (c) 2017-2019 Ben Tranter. See the [LICENSE](/LICENSE) for more info.\n","program":{"html_id":"github.com/bentranter/turbolinks/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/bentranter/turbolinks","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks","path":"Turbolinks.html","kind":"module","full_name":"Turbolinks","name":"Turbolinks","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"turbolinks/version.cr","line_number":1,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks/version.cr"},{"filename":"turbolinks.cr","line_number":7,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.2.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"Turbolinks a module that provides HTTP middleware to be used with\nTurbolinks powered frontends. It handles form submission, and redirection.","summary":"

Turbolinks a module that provides HTTP middleware to be used with Turbolinks powered frontends.

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/bentranter/turbolinks/Turbolinks/Handler","path":"Turbolinks/Handler.html","kind":"class","full_name":"Turbolinks::Handler","name":"Handler","abstract":false,"superclass":{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"},{"html_id":"github.com/bentranter/turbolinks/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/bentranter/turbolinks/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"turbolinks.cr","line_number":22,"url":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr"}],"repository_name":"github.com/bentranter/turbolinks","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/bentranter/turbolinks/HTTP/Handler","kind":"module","full_name":"HTTP::Handler","name":"Handler"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/bentranter/turbolinks/Turbolinks","kind":"module","full_name":"Turbolinks","name":"Turbolinks"},"doc":"A handler that handles form submission and redirection for Turbolinks\nenabled frontends. It does nothing if the frontend is not using\nTurbolinks, so it can safely be used as HTTP middleware for any\napplication.\n\nUse like you would use any HTTP middleware:\n\n require \"http/server\"\n require \"turbolinks\"\n\n HTTP::Server.new(\"127.0.0.1\", 3000, [\n Turbolinks::Handler.new,\n ]).listen\n","summary":"

A handler that handles form submission and redirection for Turbolinks enabled frontends.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"call(context:HTTP::Server::Context)-instance-method","html_id":"call(context:HTTP::Server::Context)-instance-method","name":"call","doc":"Executes the middleware. This function is called by the HTTP server\nafter you've registered it as middleware, so you won't need to use this\nfunction directly.","summary":"

Executes the middleware.

","abstract":false,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"args_string":"(context : HTTP::Server::Context)","source_link":"https://github.com/bentranter/turbolinks/blob/bd7eda6283b499ff6a7ab11ef247210bed86bc64/src/turbolinks.cr#L30","def":{"name":"call","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"HTTP::Server::Context"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if context.request.headers.get?(\"Turbolinks-Referrer\")\nelse\n return call_next(context)\nend\nif context.request.method == \"POST\"\n call_next(context)\n post(context)\n return\nend\ncheck_redirect(context)\ncall_next(context)\nget(context)\n"}}],"macros":[],"types":[]}]}]}}) \ No newline at end of file diff --git a/shard.yml b/shard.yml index c9e1a0b..2ed670c 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: turbolinks -version: 0.1.1 +version: 0.2.0 authors: - Ben Tranter diff --git a/src/turbolinks/version.cr b/src/turbolinks/version.cr index 268a31d..3a2dd28 100644 --- a/src/turbolinks/version.cr +++ b/src/turbolinks/version.cr @@ -1,3 +1,3 @@ module Turbolinks - VERSION = "0.1.1" + VERSION = "0.2.0" end