Skip to content

WIP: v3 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
70dea15
MIT-0 license
subtleGradient May 11, 2024
4ed3b47
Appify Bun
subtleGradient May 12, 2024
aca9a93
ignore logs
subtleGradient May 12, 2024
8b65d3f
hasn't worked in a long time
subtleGradient May 12, 2024
4da694b
never worked
subtleGradient May 12, 2024
b22665c
cleanup
subtleGradient May 12, 2024
30d45a3
rm xcuserdata
subtleGradient May 12, 2024
f9384fa
rm xcuserdata
subtleGradient May 12, 2024
4119c09
move stuff around
subtleGradient May 12, 2024
71f6a8a
safari web clip
subtleGradient May 12, 2024
bb5fca4
hide logs
subtleGradient May 12, 2024
35907f6
buck2 init
subtleGradient May 12, 2024
b5c84c1
chore: update .gitignore to exclude 'buck-out' directory
subtleGradient May 12, 2024
2b5e9d3
buck2 init ++
subtleGradient May 12, 2024
616cfb4
learning swift
subtleGradient May 12, 2024
4a468d6
buck2 ++
subtleGradient May 12, 2024
1cc4dfd
chore: Add Info.plist and build script for HelloWorldApp
subtleGradient May 12, 2024
7fe78e9
cleanup
subtleGradient May 13, 2024
31db3b6
ignore build
subtleGradient May 13, 2024
efb377c
bundling ++
subtleGradient May 13, 2024
ed32fa3
bunp buck2 prelude
subtleGradient May 13, 2024
31fddd9
color-scheme: light dark
subtleGradient May 13, 2024
afbb5ce
reorg
subtleGradient May 13, 2024
8fcdae7
+ bundle script
subtleGradient May 13, 2024
dd5a077
reorg scripts
subtleGradient May 13, 2024
5694ef1
WIP
subtleGradient May 18, 2024
d9dd02a
Update prelude subproject commit
subtleGradient May 18, 2024
01afb12
chore: Add script to copy combined Swift files to clipboard
subtleGradient May 18, 2024
8f9072c
feat: Add Cocoa application functionality to HelloWorldApp
subtleGradient May 18, 2024
a5c9462
hello world app window works
subtleGradient May 18, 2024
8052aae
quit app when last window closes
subtleGradient May 18, 2024
0daf312
basic menu bar via code
subtleGradient May 18, 2024
7d9e6f2
feat: Add new window functionality to HelloWorldApp
subtleGradient May 18, 2024
7f73250
23 ++
subtleGradient May 19, 2024
08736f1
- BUCK
subtleGradient May 19, 2024
07c2509
icon
subtleGradient May 19, 2024
252cd59
23 ++
subtleGradient May 19, 2024
10278ae
cleanup
subtleGradient May 19, 2024
6baee33
cleanup folders
subtleGradient May 19, 2024
29e42fe
++
subtleGradient May 20, 2024
eaf4525
chore: Improve just-in-time compiling and execute JXA script asynchro…
subtleGradient May 20, 2024
d375b97
WIP 🤷‍♂️
subtleGradient Jun 2, 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.tmproj
.DS_Store
*.app.log
*.log
**/xcuserdata/**
buck-out
.build
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"[plist]": {
"editor.formatOnSave": false
}
}
66 changes: 66 additions & 0 deletions Create Appify UI.app/Contents/Resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!doctype html><meta charset=utf-8>
<title>Appify</title>


<style>
:root{
color-scheme: light dark;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
"Helvetica Neue", sans-serif;
}

html,body,input
{font-size:12px;}

h1,h2,h3,h4,h5,h6{font-weight:normal; margin:0; padding:0;}
html{padding:1rem;}
h3{font-family:Georgia;}

h1>sub{font-size:1ex;}

a:link{color:inherit;}
.focus a:link{color:#00A;}

.focus h1>strong{color:#000;}

h1{border-bottom:1px dotted;padding-bottom:.5ex;margin-bottom:.5ex;}
h2{font-size:1.2rem;letter-spacing:.3ex;word-spacing:.51ex;}

body{text-align:center;}

form{text-align:right;display:inline-block;}
input:not([type=submit]){width:40ex; background-color: #55555555;}
input[type=submit]{font-size:2em;}

p{max-width:44ex; text-align:left; margin-left:auto}
</style>


<script>
onblur = function(){document.documentElement.className='blur'}
onfocus = function(){document.documentElement.className='focus'}
onload = function(){
onfocus()
}
</script>

<form action=http://localhost:9999>
<input type="hidden" name="XSRF_TOKEN">
<script> document.querySelector('input[name=XSRF_TOKEN]').value = new URLSearchParams(location.search).get('XSRF_TOKEN') ?? alert('Error: XSRF_TOKEN missing') </script>
<label>CFBundleName <input name=CFBundleName value="My Appified App"></label>
<p></p>
<label>CFBundleExecutable <input name=CFBundleExecutable value=app.sh></label>
<p></p>
<label>CFBundleIdentifier <input name=CFBundleIdentifier value=my.appified.app></label>
<p></p>
<label>CFBundleIconFile <input name=CFBundleIconFile value=MyAwesomeIcon.icns></label>
<p></p>
<label>NSHumanReadableCopyright <input name=NSHumanReadableCopyright value="© Copyright 2012 My Name Here"></label>
<p></p>
<label>CFBundleShortVersionString <input name=CFBundleShortVersionString value=0.1></label>
<p><small>Marketing version number for users to see.</small></p>
<label>CFBundleVersion <input name=CFBundleVersion placeholder=00001.00.00d value=0.1></label>
<p><small>Launch Services expects the following format: <code>nnnnn[.nn[.nn]][X]</code> where n is a digit 0-9, square brackets indicate optional components, and X is any string not starting with a digit. X is ignored when present.</small></p>

<input type=submit value="Create macOS App">
</form>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const __filename = decodeURIComponent(new URL(import.meta.url).pathname)
const __dirname = __filename.slice(0, __filename.lastIndexOf("/"))

import { open } from "./webview.ts"
import { type Handler, Server } from "https://deno.land/std@0.182.0/http/server.ts"
import { open } from "./webview.ts"

export function create(handler: Handler) {
let port = 8444
Expand All @@ -22,7 +22,7 @@ export function create(handler: Handler) {
return server
}

import { html, css } from "./html.ts"
import { css, html } from "./html.ts"

if (import.meta.main) {
console.log("webview works?")
Expand All @@ -32,6 +32,7 @@ if (import.meta.main) {

const styles = css`
:root {
color-scheme: light dark;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
"Helvetica Neue", sans-serif;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const __filename = decodeURIComponent(new URL(import.meta.url).pathname)
const __dirname = __filename.slice(0, __filename.lastIndexOf("/"))

import { css, html } from "./lib/html.ts"
import * as webviewServer from "./lib/http-webview.ts"
import { html, css } from "./lib/html.ts"

const handlerMainView = (_req: Request): Response => {
console.log("webview works!")

const styles = css`
:root {
color-scheme: light dark;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
"Helvetica Neue", sans-serif;
}
Expand Down
14 changes: 14 additions & 0 deletions Example Apps/Appify UI 2011.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundlePackageType</key><string>APPL</string><key>CFBundleInfoDictionaryVersion</key><string>6.0</string>

<key>CFBundleName</key> <string>Appify UI</string>
<key>CFBundleExecutable</key> <string>appify-ui.sh</string>
<key>CFBundleIdentifier</key> <string>com.SubtleGradient.AppifyUI</string>

<key>CFBundleVersion</key> <string>1.0</string>
<key>CFBundleGetInfoString</key> <string>1.0 Appified by Thomas Aylott on Sat Dec 3 2011</string>
<key>CFBundleShortVersionString</key> <string>1.0</string>

<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

</dict></plist>
Binary file not shown.
140 changes: 140 additions & 0 deletions Example Apps/Appify UI 2011.app/Contents/MacOS/appify-ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/usr/bin/env bash
#
# MIT License
#
# Created By
# Thomas Aylott <http://subtlegradient.com>
#
# Special Thanks
# Mathias Bynens <http://mathiasbynens.be>
# Shazron Abdullah <http://www.shazron.com>
# Apache Callback Mac (heavily modified) <https://github.com/subtleGradient/callback-mac>
# Marc Wäckerlin <http://marc.waeckerlin.org/computer/blog/parsing_of_query_string_in_bash_cgi_scripts>


# Decodes an URL-string
# an URL encoding has "+" instead of spaces
# and no special characters but "%HEX"
function urlDec() {
local value=${*//+/%20} # replace +-spaces by %20 (hex)
for part in ${value//%/ \\x}; do # split at % prepend \x for printf
printf "%b%s" "${part:0:4}" "${part:4}" # output decoded char
done
}

# For all given query strings
# parse them an set shell variables
function setQueryVars() {
local vars="$(cat)"
local vars="${vars//\*/%2A}" # escape * as %2A
for var in ${vars//&/ }; do # split at &
local value=$(urlDec "${var#*=}") # decode value after =
value=${value//\\/\\\\} # change \ to \\ for later
eval "CGI_${var%=*}=\"${value//\"/\\\"}\"" # evaluate assignment
done
}

function handleForm () {
appify
}

function appify () {
setQueryVars

cd "$HOME/Desktop"

# Options
local appify_FILE="$CGI_CFBundleExecutable"
local appify_NAME="$CGI_CFBundleName"
local appify_ROOT="$appify_NAME.appify/Contents/MacOS"
local appify_INFO="$appify_ROOT/../Info.plist"

if [[ "$appify_FILE" == "" ]]; then
echo "CFBundleExecutable is required. Aborting" 1>&2
exit 1
fi

# Create the bundle
if [[ -a "$appify_NAME.appify" ]]; then
echo "$PWD/$appify_NAME.appify already exists :(" 1>&2
exit 1
fi
mkdir -p "$appify_ROOT"


# Create a new blank CFBundleExecutable
cat <<-EOF > "$appify_ROOT/$appify_FILE"
#!/usr/bin/env bash
# launch the cocoa app
cd "\$(dirname "\$0")"
./apache-callback-mac -url "file://\$(dirname "\$0")/../Resources/index.html"
EOF
echo "Created blank '$appify_ROOT/$appify_FILE' be sure to edit this file to make it do things and stuff" 1>&2

chmod +x "$appify_ROOT/$appify_FILE"

cp "$(dirname "$0")/apache-callback-mac" "$appify_ROOT/"
mkdir -p "$appify_ROOT/../Resources/English.lproj"
cp "$(dirname "$0")/../Resources/English.lproj/MainMenu.nib" "$appify_ROOT/../Resources/English.lproj/MainMenu.nib"
cat <<-EOF > "$appify_ROOT/../Resources/index.html"
<!doctype html>
<meta charset=utf-8>
<title>$appify_NAME</title>
<style>html{font-family:"Lucida Grande"; font-size:12px; border-top:1px solid #8A8A8A; background:#E8E8E8;}</style>
$appify_NAME
EOF

# Create the Info.plist
cat <<-EOF > "$appify_INFO"
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>CFBundlePackageType</key><string>APPL</string><key>CFBundleInfoDictionaryVersion</key><string>6.0</string>

<key>CFBundleIconFile</key> <string>$CGI_CFBundleIconFile</string>

<key>CFBundleName</key> <string>$CGI_CFBundleName</string>
<key>CFBundleExecutable</key> <string>$CGI_CFBundleExecutable</string>
<key>CFBundleIdentifier</key> <string>$CGI_CFBundleIdentifier</string>

<key>CFBundleVersion</key> <string>$CGI_CFBundleVersion</string>
<key>NSHumanReadableCopyright</key> <string>$CGI_NSHumanReadableCopyright</string>
<key>CFBundleShortVersionString</key> <string>$CGI_CFBundleShortVersionString</string>

<!-- Needed for Apache Callback -->
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSMainNibFile</key><string>MainMenu</string>

</dict></plist>
EOF

# Appify!
if [[ -a "$appify_NAME.app" ]]; then
echo "$appify_NAME.app already exists :(" 1>&2
exit 1
fi
mv "$appify_NAME.appify" "$appify_NAME.app"

exit
}

function waitForFormData () {
cat <<EOF\
| nc -l 9999\
| head -1\
| cut -d' ' -f2\
| cut -d'?' -f2
HTTP/1.0 200 OK
Content-Type: text/html

Appified on `date`
EOF
}


# async HTTP server
waitForFormData | handleForm &

# launch the cocoa app
cd "$(dirname "$0")"
./apache-callback-mac

# close nc just in case
nc localhost 9999 > /dev/null
Binary file not shown.
Loading