chore: remove orgize-demos package

This commit is contained in:
PoiScript 2019-10-10 13:41:35 +08:00
parent 26d68ebebb
commit 499f0de508
7 changed files with 1 additions and 147 deletions

View file

@ -1,4 +1,5 @@
language: rust
rust:
- stable
- nightly
@ -16,13 +17,6 @@ script:
- cargo fmt --all -- --check
- cargo test --all-features
deploy:
provider: heroku
api_key: $HEROKU_API_KEY
app: orgize
on:
condition: "$TRAVIS_RUST_VERSION == stable"
notifications:
email:
on_failure: change

View file

@ -8,7 +8,6 @@ readme = "README.md"
edition = "2018"
license = "MIT"
keywords = ["orgmode", "emacs", "parser"]
exclude = ["/demos", "/fuzz"]
[package.metadata.docs.rs]
all-features = true

View file

@ -1 +0,0 @@
web: ./target/release/orgize-demos

View file

@ -1 +0,0 @@
BUILD_PATH="demos"

1
demos/.gitignore vendored
View file

@ -1 +0,0 @@
target

View file

@ -1,15 +0,0 @@
[package]
name = "orgize-demos"
version = "0.1.0"
authors = ["PoiScript <poiscript@gmail.com>"]
edition = "2018"
publish = false
[profile.release]
lto = true
[dependencies]
actix-web = { version = "1.0.8", default-features = false }
orgize = { path = "..", features = ["syntect"] }
serde = { version = "1.0.101", features = ["derive"] }
serde_json = "1.0.41"

View file

@ -1,121 +0,0 @@
use actix_web::{get, post, web, App, HttpResponse, HttpServer};
use orgize::Org;
use serde::Deserialize;
use std::env;
use std::io::Result;
use orgize::export::html::{DefaultHtmlHandler, SyntectHtmlHandler};
use orgize::syntect::html::IncludeBackground;
#[get("/")]
fn index() -> HttpResponse {
HttpResponse::Ok().content_type("text/html").body(
r#"<h3><a href="https://github.com/PoiScript/orgize">Orgize</a> demos</h3>
<form action="/export" method="post">
<p>Input content:</p>
<div>
<textarea name="content" rows="10" cols="100">
* DONE Title :tag:
#+BEGIN_SRC rust
println!("Hello");
#+END_SRC
</textarea>
</div>
<p>Output format:</p>
<input type="radio" name="format" value="json" checked> Json<br>
<input type="radio" name="format" value="html"> HTML<br>
<input type="radio" name="format" value="org"> Org<br>
<input type="radio" name="format" value="syntect"> HTML with highlight<br>
<p>Highlight theme:</p>
<select name="theme">
<option value="InspiredGitHub" selected="selected">InspiredGitHub</option>
<option value="base16-ocean.dark">base16-ocean.dark</option>
<option value="base16-eighties.dark">base16-eighties.dark</option>
<option value="base16-mocha.dark">base16-mocha.dark</option>
<option value="base16-ocean.light">base16-ocean.light</option>
<option value="Solarized (dark)">Solarized (dark)</option>
<option value="Solarized (light)">Solarized (light)</option>
</select>
<p>Highlight background:</p>
<select name="background">
<option value="no" selected="selected">No</option>
<option value="yes">Yes</option>
</select>
<p><input type="submit" value="Submit"></p>
</form>"#,
)
}
#[derive(Deserialize)]
struct FormData {
format: String,
content: String,
theme: String,
background: String,
}
#[post("/export")]
fn export(form: web::Form<FormData>) -> Result<HttpResponse> {
let org = Org::parse(&form.content);
match &*form.format {
"json" => Ok(HttpResponse::Ok()
.content_type("application/json")
.body(serde_json::to_string(&org)?)),
"html" => {
let mut writer = Vec::new();
org.html(&mut writer)?;
Ok(HttpResponse::Ok()
.content_type("text/html")
.body(String::from_utf8(writer).unwrap()))
}
"syntect" => {
let mut handler = SyntectHtmlHandler::new(DefaultHtmlHandler);
match &*form.theme {
"InspiredGitHub"
| "base16-ocean.dark"
| "base16-eighties.dark"
| "base16-mocha.dark"
| "base16-ocean.light"
| "Solarized (dark)"
| "Solarized (light)" => handler.theme = form.theme.clone(),
_ => return Ok(HttpResponse::BadRequest().body("Unsupported theme".to_string())),
}
match &*form.background {
"yes" => handler.background = IncludeBackground::Yes,
"no" => handler.background = IncludeBackground::No,
_ => {
return Ok(HttpResponse::BadRequest().body("Unsupported background".to_string()))
}
}
let mut writer = Vec::new();
org.html_with_handler(&mut writer, &mut handler)?;
Ok(HttpResponse::Ok()
.content_type("text/html")
.body(String::from_utf8(writer).unwrap()))
}
"org" => {
let mut writer = Vec::new();
org.org(&mut writer)?;
Ok(HttpResponse::Ok()
.content_type("text/plain")
.body(String::from_utf8(writer).unwrap()))
}
_ => Ok(HttpResponse::BadRequest().body("Unsupported format".to_string())),
}
}
fn main() -> Result<()> {
let port = env::var("PORT")
.unwrap_or_else(|_| "3000".into())
.parse()
.expect("PORT must be a number");
HttpServer::new(|| App::new().service(index).service(export))
.bind(("0.0.0.0", port))?
.run()
}