aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md14
-rw-r--r--src/get_routes.rs28
-rw-r--r--src/lua.rs43
3 files changed, 0 insertions, 85 deletions
diff --git a/README.md b/README.md
index 9a2ba59..90d857b 100644
--- a/README.md
+++ b/README.md
@@ -111,20 +111,6 @@ Note that:
* Note that none of these constructs can be nested. E.g. `{{foo|{{bar}} }}` or
`{{foo|<raw>test</raw>}}` will not work as you might expect.
-## Lua shebangs
-
-Files can start with a shebang like `#!hello`, which will
-interpret the following text with the `view` function returned
-by in this case `bin/hello.lua`, e.g.
-
-```lua
-function view(text)
- return '<pre>' .. gitpad.html_escape(string.upper(text)) .. '</pre>'
-end
-
-return {view=view}
-```
-
## Contributing
Feedback, bug reports and suggestions are welcome!
diff --git a/src/get_routes.rs b/src/get_routes.rs
index 951c7b6..10d3476 100644
--- a/src/get_routes.rs
+++ b/src/get_routes.rs
@@ -11,7 +11,6 @@ use hyper::http::request::Parts;
use serde::Deserialize;
use sputnik::html_escape;
use sputnik::request::SputnikParts;
-use std::fmt::Write;
use std::str::from_utf8;
use crate::action_links;
@@ -81,33 +80,6 @@ fn view_blob<C: Controller>(
match from_utf8(blob.content()) {
Ok(text) => {
- #[cfg(feature = "lua")]
- if let Some(script) = super::lua::parse_shebang(text) {
- match script.run(&ctx) {
- Ok(output) => {
- write!(
- page.body,
- "<div>rendered with <a href='{}'>{}</a></div>",
- html_escape(
- controller.build_url_path(&ctx.branch, &script.module_path())
- ),
- html_escape(script.lua_module_name)
- );
- page.body.push_str(&output);
- }
- Err(err) => {
- write!(
- page.body,
- "<div class=error><a href='{}'>{}</a>: {err}</div>",
- html_escape(
- controller.build_url_path(&ctx.branch, &script.module_path())
- ),
- html_escape(script.lua_module_name)
- );
- }
- };
- return Ok(page.into());
- }
if let Some(renderer) = get_renderer(&ctx.path) {
renderer(text, &mut page, RenderMode::View, &ctx);
} else {
diff --git a/src/lua.rs b/src/lua.rs
index 5caf3f1..e9c4841 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -16,23 +16,6 @@ use self::template::ArgIndex;
mod serde;
pub mod template;
-pub struct Script<'a> {
- pub lua_module_name: &'a str,
- input: &'a str,
-}
-
-pub fn parse_shebang(text: &str) -> Option<Script> {
- if let Some(rest) = text.strip_prefix("#!") {
- if let Some((lua_module_name, input)) = rest.split_once('\n') {
- return Some(Script {
- lua_module_name,
- input,
- });
- }
- }
- None
-}
-
pub enum ScriptError {
ModuleNotFound,
ModuleNotUtf8,
@@ -90,32 +73,6 @@ pub fn lua_context<A>(run: impl FnOnce(rlua::Context) -> rlua::Result<A>) -> rlu
})
}
-impl<'a> Script<'a> {
- pub fn module_path(&self) -> String {
- format!("bin/{}.lua", self.lua_module_name)
- }
-
- pub fn run(&self, ctx: &Context) -> Result<String, ScriptError> {
- let filename = self.module_path();
-
- let lua_entr = ctx
- .branch_head()
- .unwrap()
- .tree()
- .and_then(|tree| tree.get_path(Path::new(&filename)))
- .map_err(|_| ScriptError::ModuleNotFound)?;
-
- let lua_blob = ctx.repo.find_blob(lua_entr.id()).unwrap();
- let lua_code = from_utf8(lua_blob.content()).map_err(|_| ScriptError::ModuleNotUtf8)?;
- lua_context(|ctx| {
- let module: Table = ctx.load(lua_code).eval()?;
- let view: Function = module.get("view")?;
- view.call(self.input)
- })
- .map_err(ScriptError::LuaError)
- }
-}
-
fn module_path(module_name: &str) -> String {
format!("modules/{}.lua", module_name)
}