cleanup + git commit info
This commit is contained in:
parent
1ddc3774a1
commit
6f8a7c9cc2
15
build.sh
15
build.sh
@ -4,3 +4,18 @@ wasm-pack build --target web --release --no-typescript
|
|||||||
wasm-opt -Oz -o pkg/integral_site_bg_2.wasm pkg/integral_site_bg.wasm
|
wasm-opt -Oz -o pkg/integral_site_bg_2.wasm pkg/integral_site_bg.wasm
|
||||||
mv pkg/integral_site_bg_2.wasm pkg/integral_site_bg.wasm
|
mv pkg/integral_site_bg_2.wasm pkg/integral_site_bg.wasm
|
||||||
llvm-strip --strip-all pkg/integral_site_bg.wasm
|
llvm-strip --strip-all pkg/integral_site_bg.wasm
|
||||||
|
|
||||||
|
rm -fr tmp | true #delete tmp folder if exists
|
||||||
|
mkdir tmp tmp/pkg
|
||||||
|
cp -r pkg/integral_site_bg.wasm pkg/integral_site.js tmp/pkg/
|
||||||
|
cp www/index.html www/style.css tmp/
|
||||||
|
|
||||||
|
sed -i 's/\.\.\/pkg/\.\/pkg/g' tmp/index.html
|
||||||
|
|
||||||
|
git ls-files --exclude-standard --others . >/dev/null 2>&1; ec=$?
|
||||||
|
if test "$ec" = 0; then
|
||||||
|
echo some untracked files
|
||||||
|
elif test "$ec" = 1; then
|
||||||
|
commit=$(git rev-parse HEAD)
|
||||||
|
sed -i "s/let commit = ''/let commit = '${commit}'/g" tmp/index.html
|
||||||
|
fi
|
||||||
|
|||||||
14
push.sh
14
push.sh
@ -3,20 +3,6 @@ set -e #kill script if error occurs
|
|||||||
|
|
||||||
bash build.sh
|
bash build.sh
|
||||||
|
|
||||||
rm -fr tmp | true #delete tmp folder if exists
|
|
||||||
mkdir tmp tmp/pkg
|
|
||||||
cp -r pkg/integral_site_bg.wasm pkg/integral_site.js tmp/pkg/
|
|
||||||
cp www/index.html www/style.css tmp/
|
|
||||||
|
|
||||||
sed -i 's/\.\.\/pkg/\.\/pkg/g' tmp/index.html
|
|
||||||
|
|
||||||
# put the commit at the beginning of index.html
|
|
||||||
mv tmp/index.html tmp/index.html.bak
|
|
||||||
commit_comment="<!-- Commit: $(git rev-parse HEAD) -->"
|
|
||||||
echo $commit_comment > tmp/index.html
|
|
||||||
cat tmp/index.html.bak >> tmp/index.html
|
|
||||||
rm -fr tmp/index.html.bak
|
|
||||||
|
|
||||||
echo "rsyncing"
|
echo "rsyncing"
|
||||||
rsync -av --delete --info=progress2 tmp/ rpi-public:/mnt/hdd/http_share/integral-demo/
|
rsync -av --delete --info=progress2 tmp/ rpi-public:/mnt/hdd/http_share/integral-demo/
|
||||||
rsync -av --delete --info=progress2 --exclude=".git" tmp/ ../integral-demo/
|
rsync -av --delete --info=progress2 --exclude=".git" tmp/ ../integral-demo/
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use crate::misc::{digits_precision, test_func, Cache};
|
|||||||
use eframe::{egui, epi};
|
use eframe::{egui, epi};
|
||||||
use egui::plot::{Line, Plot, Value, Values};
|
use egui::plot::{Line, Plot, Value, Values};
|
||||||
use egui::widgets::plot::{Bar, BarChart};
|
use egui::widgets::plot::{Bar, BarChart};
|
||||||
use egui::Color32;
|
use egui::{Color32, TextStyle, Vec2, Layout};
|
||||||
|
|
||||||
pub struct MathApp {
|
pub struct MathApp {
|
||||||
func_str: String,
|
func_str: String,
|
||||||
@ -16,10 +16,11 @@ pub struct MathApp {
|
|||||||
chart_manager: ChartManager,
|
chart_manager: ChartManager,
|
||||||
back_cache: Cache<Vec<Value>>,
|
back_cache: Cache<Vec<Value>>,
|
||||||
front_cache: Cache<(Vec<Bar>, f64)>,
|
front_cache: Cache<(Vec<Bar>, f64)>,
|
||||||
|
commit: String
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MathApp {
|
impl MathApp {
|
||||||
fn default() -> Self {
|
pub fn new(commit: String) -> Self {
|
||||||
let def_func = "x^2".to_string();
|
let def_func = "x^2".to_string();
|
||||||
let def_min_x = -10.0;
|
let def_min_x = -10.0;
|
||||||
let def_max_x = 10.0;
|
let def_max_x = 10.0;
|
||||||
@ -35,11 +36,10 @@ impl Default for MathApp {
|
|||||||
chart_manager: ChartManager::new(def_func, def_min_x, def_max_x, def_interval, def_resolution),
|
chart_manager: ChartManager::new(def_func, def_min_x, def_max_x, def_interval, def_resolution),
|
||||||
back_cache: Cache::new_empty(),
|
back_cache: Cache::new_empty(),
|
||||||
front_cache: Cache::new_empty(),
|
front_cache: Cache::new_empty(),
|
||||||
|
commit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl MathApp {
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_back(&mut self) -> Line {
|
fn get_back(&mut self) -> Line {
|
||||||
let data = if self.back_cache.is_valid() {
|
let data = if self.back_cache.is_valid() {
|
||||||
@ -102,15 +102,25 @@ impl epi::App for MathApp {
|
|||||||
chart_manager,
|
chart_manager,
|
||||||
back_cache,
|
back_cache,
|
||||||
front_cache,
|
front_cache,
|
||||||
|
commit,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
// Note: This Instant implementation does not show microseconds when using wasm.
|
// Note: This Instant implementation does not show microseconds when using wasm.
|
||||||
let start = instant::Instant::now();
|
let start = instant::Instant::now();
|
||||||
|
|
||||||
|
// Cute little window that lists supported functions!
|
||||||
|
// TODO: add more detail
|
||||||
|
egui::Window::new("Supported Functions").show(ctx, |ui| {
|
||||||
|
ui.label("- sqrt, abs");
|
||||||
|
ui.label("- exp, ln, log10 (log10 can also be called as log)");
|
||||||
|
ui.label("- sin, cos, tan, asin, acos, atan, atan2");
|
||||||
|
ui.label("- sinh, cosh, tanh, asinh, acosh, atanh");
|
||||||
|
ui.label("- floor, ceil, round");
|
||||||
|
ui.label("- signum, min, max");
|
||||||
|
});
|
||||||
|
|
||||||
let mut parse_error: String = "".to_string();
|
let mut parse_error: String = "".to_string();
|
||||||
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
egui::SidePanel::left("side_panel").resizable(false).show(ctx, |ui| {
|
||||||
ui.heading("Side Panel");
|
ui.heading("Side Panel");
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@ -140,11 +150,21 @@ impl epi::App for MathApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.add(egui::Slider::new(num_interval, NUM_INTERVAL_RANGE).text("Interval"));
|
ui.add(egui::Slider::new(num_interval, NUM_INTERVAL_RANGE).text("Interval"));
|
||||||
|
// ui.add_space(ui.text_style_height(&TextStyle::Body)*10.0);
|
||||||
ui.hyperlink_to(
|
ui.hyperlink_to(
|
||||||
"I'm Opensource! (and licensed under AGPLv3)",
|
"I'm Opensource! (and licensed under AGPLv3)",
|
||||||
"https://github.com/Titaniumtown/integral_site",
|
"https://github.com/Titaniumtown/integral_site",
|
||||||
);
|
);
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.with_layout(egui::Layout::top_down_justified(egui::Align::Min), |ui| {
|
||||||
|
if commit.is_empty() {
|
||||||
|
ui.label(format!("Current build is untracked!"));
|
||||||
|
} else {
|
||||||
|
ui.label("Commit: ");
|
||||||
|
ui.hyperlink_to(commit.clone(), format!("https://github.com/Titaniumtown/integral_site/commit/{}", commit));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if parse_error.is_empty() {
|
if parse_error.is_empty() {
|
||||||
@ -189,16 +209,5 @@ impl epi::App for MathApp {
|
|||||||
duration
|
duration
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cute little window that lists supported functions!
|
|
||||||
// TODO: add more detail
|
|
||||||
egui::Window::new("Supported Functions").show(ctx, |ui| {
|
|
||||||
ui.label("- sqrt, abs");
|
|
||||||
ui.label("- exp, ln, log10 (log10 can also be called as log)");
|
|
||||||
ui.label("- sin, cos, tan, asin, acos, atan, atan2");
|
|
||||||
ui.label("- sinh, cosh, tanh, asinh, acosh, atanh");
|
|
||||||
ui.label("- floor, ceil, round");
|
|
||||||
ui.label("- signum, min, max");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ extern "C" {
|
|||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
pub fn start(canvas_id: &str, commit: &str) -> Result<(), wasm_bindgen::JsValue> {
|
||||||
log("Initializing...");
|
log("Initializing...");
|
||||||
|
|
||||||
// See performance in browser profiler!
|
// See performance in browser profiler!
|
||||||
@ -39,6 +39,6 @@ pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
|||||||
log("Finished initializing!");
|
log("Finished initializing!");
|
||||||
|
|
||||||
log("Starting App...");
|
log("Starting App...");
|
||||||
let app = egui_app::MathApp::default();
|
let app = egui_app::MathApp::new(commit.to_string());
|
||||||
eframe::start_web(canvas_id, Box::new(app))
|
eframe::start_web(canvas_id, Box::new(app))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ mod misc;
|
|||||||
// For running the program natively! (Because why not?)
|
// For running the program natively! (Because why not?)
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = egui_app::MathApp::default();
|
let app = egui_app::MathApp::new("".to_string());
|
||||||
let options = eframe::NativeOptions {
|
let options = eframe::NativeOptions {
|
||||||
// Let's show off that we support transparent windows
|
// Let's show off that we support transparent windows
|
||||||
transparent: true,
|
transparent: true,
|
||||||
|
|||||||
@ -3,13 +3,4 @@ set -e
|
|||||||
|
|
||||||
bash build.sh
|
bash build.sh
|
||||||
|
|
||||||
rustup target add wasm32-unknown-unknown
|
basic-http-server tmp/
|
||||||
|
|
||||||
if [ -z "$(cargo install --list | grep wasm-pack)" ]
|
|
||||||
then
|
|
||||||
cargo install wasm-pack
|
|
||||||
fi
|
|
||||||
|
|
||||||
wasm-pack build --release --target web --no-typescript
|
|
||||||
|
|
||||||
basic-http-server
|
|
||||||
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Integral Demonstration</title>
|
<title>Integral Demonstration</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
@ -18,9 +17,10 @@
|
|||||||
import init, { start } from '../pkg/integral_site.js';
|
import init, { start } from '../pkg/integral_site.js';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
await init();
|
await init();
|
||||||
|
|
||||||
start("canvas");
|
let commit = '';
|
||||||
|
start("canvas", commit);
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user