Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a0a5a2f
should fix a few issues
GStudiosX2 Jun 5, 2024
9811504
feat: require now supports relative paths (eg: scripts/module.lua)
GStudiosX2 Jun 5, 2024
0e080dd
feat: require relative paths should fully work in all cases
GStudiosX2 Jun 5, 2024
f2e9811
feat: require relative paths should fully work in all cases
GStudiosX2 Jun 5, 2024
ad9ed9a
Merge branch 'face-hh:master' into master
GStudiosX2 Jun 5, 2024
273071f
add a few more examples and move napture/test to napture/examples/full
GStudiosX2 Jun 5, 2024
53872bb
feat: render html elements in li
GStudiosX2 Jun 5, 2024
bbf88df
revert Cargo.toml
GStudiosX2 Jun 5, 2024
fdd8c69
feat: input default values, fix: don't try to request to DNS when usi…
GStudiosX2 Jun 6, 2024
0efec4e
add back Cargo.toml
GStudiosX2 Jun 6, 2024
01e73fb
also don't request to dns for http/https links
GStudiosX2 Jun 6, 2024
443a01e
feat: set_inner_html, append_html (working draft)
GStudiosX2 Jun 6, 2024
82550c1
revert Cargo.toml
GStudiosX2 Jun 6, 2024
6746199
Merge branch 'face-hh:master' into master
GStudiosX2 Jun 6, 2024
752b8ab
Merge branch 'face-hh:master' into master
GStudiosX2 Jun 6, 2024
97fe648
made lua.rs less lines
GStudiosX2 Jun 6, 2024
edee6d7
should fix github links where the last segment contains a dot
GStudiosX2 Jun 6, 2024
db169f3
add user agent to requests
GStudiosX2 Jun 6, 2024
8f0cf88
require is now relative to the scripts path
GStudiosX2 Jun 7, 2024
2bb2454
fix non relatice paths
GStudiosX2 Jun 7, 2024
f9e63a7
fix conflicts
GStudiosX2 Jun 7, 2024
bbfe2a1
feat: allow ../ for reqiure
GStudiosX2 Jun 8, 2024
345cd39
remove leading slash added to json.ip
GStudiosX2 Jun 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions napture/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions napture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
adw = { version = "0.6.0", package = "libadwaita", features = ["v1_5"] }
adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] }
base64 = "0.22.1"
chrono = "0.4.38"
const_format = "0.2.32"
directories = "5.0.1"
glib = "0.19.4"
gtk = { version = "0.8.1", package = "gtk4", features = ["v4_14"] }
gtk = { version = "0.8.1", package = "gtk4", features = ["v4_12"] }
html-escape = "0.2.13"
html_parser = "0.7.0"
lazy_static = "1.4.0"
Expand Down
9 changes: 9 additions & 0 deletions napture/examples/base64_images/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>base64_images</title>
</head>
<body>
<p>base64 images</p>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAADMElEQVR4nOzVwQnAIBQFQYXff81RUkQCOyDj1YOPnbXWPmeTRef+/3O/OyBjzh3CD95BfqICMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMO0TAAD//2Anhf4QtqobAAAAAElFTkSuQmCC" />
</body>
</html>
15 changes: 15 additions & 0 deletions napture/examples/clear_timeout/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>clear_timeout</title>
<script src="script.lua" />
</head>
<body>
<p>clear_timeout allows you to stop a set_timeout task</p>
<p class="text">Text</p>
<div>
<button class="timeout_btn">Test Timeout</button>
<button class="clear_timeout_btn">Clear Timeout</button>
<button class="reset_btn">Reset</button>
</div>
</body>
</html>
26 changes: 26 additions & 0 deletions napture/examples/clear_timeout/script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local timeout_btn = get("timeout_btn")
local clear_timeout_btn = get("clear_timeout_btn")
local reset_btn = get("reset_btn")
local text = get("text")
local timeout

timeout_btn.on_click(function()
if timeout ~= nil then
return
end

timeout = set_timeout(function()
text.set_content("Different Text")
timeout = nil
end, 3000)
end)

clear_timeout_btn.on_click(function()
if timeout == nil then return end
clear_timeout(timeout)
timeout = nil
end)

reset_btn.on_click(function()
text.set_content("Text")
end)
15 changes: 15 additions & 0 deletions napture/examples/inner_html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>set_timeout</title>
<link href="styles.css" />
<script src="script.lua" />
</head>
<body>
<div class="text"><p>Text</p></div>
<div>
<button class="btn">Test</button>
<button class="btn2">Test 2</button>
<button class="reset_btn">Reset</button>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions napture/examples/inner_html/script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local btn = get("btn")
local btn2 = get("btn2")
local reset_btn = get("reset_btn")
local text = get("text")

btn.on_click(function()
text.append_html("<div class=\"test\"><a href=\"buss://dingle.it\">dingle</a></div>")
end)

btn2.on_click(function()
text.set_inner_html("<div class=\"test\"><a href=\"buss://dingle.it\">test</a></div>")
print(get(test))
end)

reset_btn.on_click(function()
text.set_inner_html("<p>Text</p>")
end)
8 changes: 8 additions & 0 deletions napture/examples/inner_html/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
text {
direction: column;
gap: 5px;
}

test {
font-size: 20px;
}
14 changes: 14 additions & 0 deletions napture/examples/inputs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>inputs</title>
<link href="styles.css"/>
</head>
<body>
<p>Inputs!</p>
<input class="input-long" value="inputs can have default values" />
<input class="input-long" placeholder="they also have a placeholder" />
<p>default input:</p>
<input />
</body>
</html>
4 changes: 4 additions & 0 deletions napture/examples/inputs/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
input-long {
width: 300px;
height: 35px;
}
24 changes: 24 additions & 0 deletions napture/examples/lists/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>lists</title>
<link href="styles.css">
</head>
<body>
<ol>
<li class="li">
<a href="buss://dingle.it">links ?</a>
<p>we got them 😎</p>
</li>
<li class="li">You can also just use text</li>
</ol>
<ul>
<li class="li">
<p>don't fancy a ordered style ?</p>
</li>
<li class="li">
<p class="text-big">we also have unordered lists</p>
</li>
</ul>
</body>
</html>
9 changes: 9 additions & 0 deletions napture/examples/lists/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
text-big {
font-size: 20px;
}

li {
gap: 5px;
direction: row;
}

4 changes: 4 additions & 0 deletions napture/examples/require/folder/anotherfolder/print.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
print(__script_path)
return function(arg)
print("DEBUG: " .. arg)
end
6 changes: 6 additions & 0 deletions napture/examples/require/folder/hello.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
print(__script_path)
local printtest = require("anotherfolder/print.lua")

return function()
printtest("Hello, World!")
end
14 changes: 14 additions & 0 deletions napture/examples/require/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>require</title>
<script src="script.lua" />
</head>
<body>
<p>script relative paths test</p>
<button class="startbtn">test</button>
<a class="startbtn">test</a>
<input class="input" />
<textarea class="textarea" />
</body>
</html>
7 changes: 7 additions & 0 deletions napture/examples/require/script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
print(__script_path)
local printtest = require("folder/anotherfolder/print.lua")
local hello = require("folder/hello.lua")
hello()
printtest("yo")

require("https://raw.githubusercontent.com/face-hh/webx/master/napture/test/script.lua")
1 change: 0 additions & 1 deletion napture/examples/set_timeout/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
<button class="timeout_btn3">Test Timeout Cancel</button>
<button class="reset_btn">Reset</button>
</div>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA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0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMK0CMO0TAAD//2Anhf4QtqobAAAAAElFTkSuQmCC" />
</body>
</html>
12 changes: 6 additions & 6 deletions napture/src/b9/css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ impl Styleable for gtk::Entry {

let width = properties.width;
let height = properties.height;

if width > 0 || height > 0 {
let normalized_width = if width > 0 { width } else { -1 };
let normalized_height = if height > 0 { height } else { -1 };
Expand Down Expand Up @@ -558,7 +558,7 @@ impl Styleable for gtk::Button {
self.set_margin_bottom(properties.margin_bottom.parse::<i32>().unwrap_or(0));
self.set_margin_start(properties.margin_left.parse::<i32>().unwrap_or(0));
self.set_margin_end(properties.margin_right.parse::<i32>().unwrap_or(0));

self.set_opacity(properties.opacity);

final_css += &compute_styling(class, &properties);
Expand Down Expand Up @@ -658,7 +658,7 @@ fn compute_styling(class: GString, properties: &Properties) -> String {
if properties.border_style != "none" {
borders.push_str(&format!("border-style: {};", properties.border_style));
}

format!(
"
.{} {{
Expand Down Expand Up @@ -726,8 +726,8 @@ fn get_properties(rules: &[(String, String)]) -> Properties {
.parse::<i32>()
.unwrap_or(0);
let opacity = get_rule(rules, "opacity", "1.0")
.parse::<f64>()
.unwrap_or(1.0);
.parse::<f64>()
.unwrap_or(1.0);

Properties {
direction,
Expand Down Expand Up @@ -757,6 +757,6 @@ fn get_properties(rules: &[(String, String)]) -> Properties {
padding,
gap,
font_size,
opacity
opacity,
}
}
Loading