explanations and arguments
This commit is contained in:
		@@ -1,22 +1,32 @@
 | 
			
		||||
use std::{
 | 
			
		||||
	env, fs::{File, OpenOptions},
 | 
			
		||||
	env, fs::OpenOptions, ops::Deref, include_str,
 | 
			
		||||
};
 | 
			
		||||
use memmap2::MmapOptions;
 | 
			
		||||
use rouille::{Response, router};
 | 
			
		||||
use btrfs_explorer::main_error::MainError;
 | 
			
		||||
use btrfs_explorer::render_common::http_path_set;
 | 
			
		||||
 | 
			
		||||
const CSS_FILE: &'static str = include_str!("style.css");
 | 
			
		||||
 | 
			
		||||
fn main() -> Result<(), MainError> {
 | 
			
		||||
	let filename = env::args().skip(1).next().ok_or("Argument required")?;
 | 
			
		||||
	let args: Vec<String> = env::args().collect();
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	let file = OpenOptions::new().read(true).open(filename)?;
 | 
			
		||||
	let image = unsafe { Mmap::map(&file)? };
 | 
			
		||||
	*/
 | 
			
		||||
	if args.len() < 2 {
 | 
			
		||||
		return Err("Argument required".into());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	let filename: &str = args[1].as_ref();
 | 
			
		||||
	let sockaddr: &str = args.get(2)
 | 
			
		||||
		.map_or("localhost:8080", <String as Deref>::deref);
 | 
			
		||||
	let http_path: String = args.get(3)
 | 
			
		||||
		.map_or(String::new(), <String as ToOwned>::to_owned);
 | 
			
		||||
	http_path_set(http_path);
 | 
			
		||||
 | 
			
		||||
	let file = OpenOptions::new().read(true).open(filename)?;
 | 
			
		||||
	let image = unsafe { MmapOptions::new().len(493921239040usize).map(&file)? };
 | 
			
		||||
	//	let image = unsafe { MmapOptions::new().len(493921239040usize).map(&file)? };
 | 
			
		||||
	let image = unsafe { MmapOptions::new().map(&file)? };
 | 
			
		||||
 | 
			
		||||
	rouille::start_server("127.0.0.1:8080", move |request| {
 | 
			
		||||
	rouille::start_server(sockaddr, move |request| {
 | 
			
		||||
		router!(
 | 
			
		||||
			request,
 | 
			
		||||
			(GET) ["/"] =>
 | 
			
		||||
@@ -34,8 +44,8 @@ fn main() -> Result<(), MainError> {
 | 
			
		||||
			(GET) ["/tree/{tree}/{method}/{key}", tree: String, method: String, key: String] =>
 | 
			
		||||
				btrfs_explorer::http_tree::http_tree(&image, &tree, Some(&method), Some(&key), request).unwrap(),
 | 
			
		||||
			(GET) ["/favicon.ico"] => Response::empty_404(),
 | 
			
		||||
			(GET) ["/style.css"] => Response::from_file("text/css", File::open("style.css").unwrap()),
 | 
			
		||||
			(GET) ["/htmx.min.js"] => Response::from_file("text/css", File::open("htmx.min.js").unwrap()),
 | 
			
		||||
			(GET) ["/style.css"] => Response::from_data("text/css", CSS_FILE),// Response::from_file("text/css", File::open("style.css").unwrap()),
 | 
			
		||||
//			(GET) ["/htmx.min.js"] => Response::from_file("text/css", File::open("htmx.min.js").unwrap()),
 | 
			
		||||
			_ => Response::empty_404(),
 | 
			
		||||
		)
 | 
			
		||||
	});
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										147
									
								
								btrfs_explorer_bin/src/style.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								btrfs_explorer_bin/src/style.css
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,147 @@
 | 
			
		||||
body {
 | 
			
		||||
    padding: 0.2em 2em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
div.nav {
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
    background-color: #dde;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    margin: 5px 0;
 | 
			
		||||
    overflow: hidden;
 | 
			
		||||
    text-align: center;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
a.nav {
 | 
			
		||||
    text-decoration: none;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.item {
 | 
			
		||||
    padding: 3px;
 | 
			
		||||
    background-color: #dde;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    margin: 3px 0;
 | 
			
		||||
    overflow: hidden;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
a {
 | 
			
		||||
    color: black;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
details.highlight {
 | 
			
		||||
    background-color: #bbc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
details .details {
 | 
			
		||||
    color: black;
 | 
			
		||||
//    background-color: #222;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    margin-top: 5px;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.itemvalue {
 | 
			
		||||
    color: black;
 | 
			
		||||
    padding: 3px;
 | 
			
		||||
    margin: 1px 2px;
 | 
			
		||||
    width: auto;
 | 
			
		||||
    display: inline-block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.key {
 | 
			
		||||
    color: white;
 | 
			
		||||
    background-color: #999;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    padding: 3px;
 | 
			
		||||
    margin: 1px 2px;
 | 
			
		||||
    display: inline-block;
 | 
			
		||||
    font-family: monospace;
 | 
			
		||||
    font-size: 12pt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.key a {
 | 
			
		||||
    color: white;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_id {
 | 
			
		||||
    min-width: 160px;
 | 
			
		||||
    text-align: right;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type {
 | 
			
		||||
    min-width: 160px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_offset {
 | 
			
		||||
    min-width: 160px;
 | 
			
		||||
    text-align: right;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type.inode {
 | 
			
		||||
    background-color: #c22;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type.ref {
 | 
			
		||||
    background-color: #aa5;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type.extent {
 | 
			
		||||
    background-color: #151;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type.dir {
 | 
			
		||||
    background-color: #33c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.key_type.root {
 | 
			
		||||
    background-color: #111;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
span.nodeaddr {
 | 
			
		||||
    color: white;
 | 
			
		||||
    background-color: #999;
 | 
			
		||||
    text-align: right;
 | 
			
		||||
    border-radius: 4px;
 | 
			
		||||
    padding: 3px;
 | 
			
		||||
    float: right;
 | 
			
		||||
    font-family: monospace;
 | 
			
		||||
    font-size: 12pt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.details table {
 | 
			
		||||
    border-collapse: collapse;
 | 
			
		||||
    margin-bottom: 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.details td {
 | 
			
		||||
    border: 1px solid black;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.details td:first-child {
 | 
			
		||||
    border: 1px solid black;
 | 
			
		||||
    width: 160px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.details p {
 | 
			
		||||
    padding: 0;
 | 
			
		||||
    margin: 5px 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pre {
 | 
			
		||||
    white-space: pre-wrap;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.blocks {
 | 
			
		||||
    margin: 0 auto;
 | 
			
		||||
    border-collapse: separate;
 | 
			
		||||
    border-spacing: 2px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.blocks td {
 | 
			
		||||
    height: 10px;
 | 
			
		||||
    width: 10px;
 | 
			
		||||
    padding: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
table.legend {
 | 
			
		||||
    margin: 0 auto;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user