Skip to content

Commit

Permalink
releasing 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kfix committed Feb 26, 2015
1 parent b45a556 commit a12d002
Show file tree
Hide file tree
Showing 18 changed files with 700 additions and 99 deletions.
65 changes: 36 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/usr/bin/make -f
appdir := apps
apps := Hangouts.app Trello.app Digg.app Vine.app
apps := Hangouts Trello Digg Vine
appexec := build/MacOS/MacPin
#apps := $(addsuffix .app, $(basename $(wildcard sites/*)))
#apps := $(patsubst %, %.app, $(basename $(wildcard sites/*)))
debug ?=
debug += -D APP2JSLOG -D SAFARIDBG -D WK2LOG -D DBGMENU
#debug += -D APP2JSLOG -D SAFARIDBG -D WK2LOG -D DBGMENU
#^ need to make sure !release target
#verbose := -driver-print-jobs
# ^ just a dry-run
#verbose := -v
all: $(apps)
allapps := $(patsubst %,$(appdir)/%.app,$(apps))
allapps: $(allapps)

VERSION := 1.1.0
VERSION := 1.2.0
LAST_TAG != git describe --abbrev=0 --tags
USER := kfix
REPO := MacPin
Expand All @@ -25,10 +24,6 @@ frameworks := -F $(sdkpath)/System/Library/Frameworks -F build -F build/Framewor
modincdirs := -I build -L build -L build/Frameworks
modincdirs += $(addprefix -I ,$(patsubst %/,%,$(dir $(wildcard modules/*/module.modulemap))))

#build/%.appex
#$(swiftc) -application-extension
# https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/SystemExtensionKeys.html#//apple_ref/doc/uid/TP40014212-SW15

build/MacOS/%: execs/%.swift build/Frameworks/lib%.dylib
install -d $(@D)
$(swiftc) $(debug) $(frameworks) $(modincdirs) \
Expand All @@ -48,8 +43,14 @@ build/%.a: build/%.o
ar rcs $@ $<

build/%.o: objc/%.m
build/Frameworks/lib%.dylib: modules/%/*.m
install -d $(@D)
xcrun -sdk macosx clang -c $(frameworks) -fmodules -o $@ $<

#build/%.ShareExtension.bundle: build/%.ShareExtension/*.swift
#$(swiftc) -application-extension
# https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/SystemExtensionKeys.html#//apple_ref/doc/uid/TP40014212-SW15

icons/%.icns: icons/%.png
python icons/AppleIcnsMaker.py -p $<

Expand All @@ -58,7 +59,7 @@ icons/%.icns: icons/WebKit.icns

# https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
# https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html
%.app: $(appexec) icons/%.icns sites/% entitlements.plist build/Frameworks/lib$(notdir $(appexec)).dylib
$(appdir)/%.app: $(appexec) icons/%.icns sites/% entitlements.plist build/Frameworks/lib$(notdir $(appexec)).dylib
python2.7 -m bundlebuilder \
--name=$* \
--bundle-id=com.github.kfix.$(notdir $(appexec)).$* \
Expand All @@ -68,18 +69,18 @@ icons/%.icns: icons/WebKit.icns
--file=sites/$*:Contents/Resources \
$(addprefix --lib=,$(filter %.dylib,$+)) \
build
plutil -replace CFBundleShortVersionString -string "$(VERSION)" $(appdir)/$*.app/Contents/Info.plist
plutil -replace CFBundleVersion -string "0.0.0" $(appdir)/$*.app/Contents/Info.plist
plutil -replace NSHumanReadableCopyright -string "built $(shell date) by $(shell id -F)" $(appdir)/$*.app/Contents/Info.plist
plutil -replace NSSupportsAutomaticTermination -bool true $(appdir)/$*.app/Contents/Info.plist
plutil -replace NSSupportsSuddenTermination -bool true $(appdir)/$*.app/Contents/Info.plist
-codesign -s - -f --entitlements entitlements.plist $(appdir)/$*.app && codesign -dv $(appdir)/$*.app
-asctl container acl list -file $(appdir)/$*.app

%.appex: %.app appex.plist
plutil -replace CFBundleShortVersionString -string "$(VERSION)" $@/Contents/Info.plist
plutil -replace CFBundleVersion -string "0.0.0" $@/Contents/Info.plist
plutil -replace NSHumanReadableCopyright -string "built $(shell date) by $(shell id -F)" $@/Contents/Info.plist
plutil -replace NSSupportsAutomaticTermination -bool true $@/Contents/Info.plist
plutil -replace NSSupportsSuddenTermination -bool true $@/Contents/Info.plist
-codesign -s - -f --entitlements entitlements.plist $@ && codesign -dv $@
-asctl container acl list -file $@

$(appdir)/%.appex: $(appdir)/%.app build/%.ShareExtension.bundle appex.plist
# --bundle-id=com.github.kfix.macpin.$*.Extension

install: $(apps)
install: allapps
cd $(appdir); cp -R $+ ~/Applications

clean:
Expand All @@ -89,18 +90,18 @@ clean:
uninstall:
-defaults delete $(appexec)
-rm -rf ~/Library/Caches/com.github.kfix.$(notdir $(appexec)).* ~/Library/WebKit/com.github.kfix.$(notdir $(appexec)).* ~/Library/WebKit/$(notdir $(appexec))
-rm -rf ~/Library/Saved\ Application\ State/com.github.kfix.macpin.*
-rm -rf ~/Library/Preferences/com.github.kfix.macpin.*
-rm -rf ~/Library/Saved\ Application\ State/com.github.kfix.$(notdir $(appexec)).*
-rm -rf ~/Library/Preferences/com.github.kfix.$(notdir $(appexec)).*
-cd ~/Applications; rm -rf $(apps)
-defaults read com.apple.spaces app-bindings | grep com.github.kfix.macpin.
-defaults read com.apple.spaces app-bindings | grep com.github.kfix.$(notdir $(appexec).
# open ~/Library/Preferences/com.apple.spaces.plist

test: $(appexec)
#-defaults delete $(notdir appexec)
#-defaults delete $(notdir $(appexec))
$< http://browsingtest.appspot.com

doc: $(appexec)
echo ":print_module MacPin" | xcrun swift $(modincdirs) -deprecated-integrated-repl
echo ":print_module $(notdir $(appexec))" | xcrun swift $(modincdirs) -deprecated-integrated-repl

nightly: $(appexec) DYLD_FRAMEWORK_PATH=/Volumes/WebKit/WebKit.app/Contents/Frameworks/10.10
-defaults delete $(notdir $(appexec))
Expand All @@ -112,13 +113,19 @@ tag:

$(ZIP): tag
rm $(ZIP) || true
cd $(appdir); zip -no-wild -r ../$@ $(apps) --exclude .DS_Store
zip -no-wild -r $@ $(allapps) --exclude .DS_Store

release: clean $(apps) $(ZIP)
ifneq ($(GITHUB_ACCESS_TOKEN),)
release: clean allapps $(ZIP)
git push -f --tags
posturl=$$(curl --data $(GH_RELEASE_JSON) "https://api.github.com/repos/$(USER)/$(REPO)/releases?access_token=$(GITHUB_ACCESS_TOKEN)" | jq -r .upload_url | sed 's/[\{\}]//g') && \
dload=$$(curl --fail -X POST -H "Content-Type: application/gzip" --data-binary "@$(ZIP)" "$$posturl=$(ZIP)&access_token=$(GITHUB_ACCESS_TOKEN)" | jq -r .browser_download_url | sed 's/[\{\}]//g') && \
echo "$(REPO) now available for download at $$dload"
else
release:
@echo You need to export \$$GITHUB_ACCESS_TOKEN to make a release!
@exit 1
endif

.PRECIOUS: icons/%.icns $(appdir)/%.app build/Frameworks/lib%.dylib
.PHONY: clean install uninstall test all tag release nightly doc
.PHONY: clean install uninstall test allapps tag release nightly doc
154 changes: 86 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,112 @@
MacPin
=======
MacPin creates a hybrid OSX & Web app from a simple Javascript.
It appears as a very stripped down browser with just a tab-bar (aka. "Site Specific Browser").
You can see it in your App Switcher and it can post to Notification Center and recieve custom-scheme URLs opened on your Mac via Launch Services.
# MacPin
MacPin creates a Mac OSX App shell for websites & webapps from a short JavaScript you provide.
Some call these Apps [Site-specific Browsers](https://en.wikipedia.org/wiki/Site-specific_browser) or Hybrid apps.

(OSX 10.10 "Yosemite" required)
The Browser UI is very minimal, just a tab-bar which disappears in Full-Screen mode, leaving only the site content.

Included Apps
======
MacPin apps sit in your Dock, App Switcher, and Launchpad.
Userscripts can be injected to facilitate posting to the Notification Center & recalling webapp locations/state from those posts.

* [Hangouts.app](http://plus.google.com/hangouts)
===
Chrome-less Hangouts client for your desktop.
![screenie](/sites/Hangouts/screenshot.jpg?raw=true)
Load up does take about 30 secs, so be patient.
New incoming messages are shown in OSX's Notification Center, clicking them will popup the contact in the app so you can reply quickly.
Custom URL schemes can also be registered to launch your App from any other app on your Mac.

```
# URLs:
sms:5558675309
tel:18001234567
hangouts:[email protected]
```
Included is an OSX Service that allows highlighting a phone number in any text and right clicking to open a Hangout Call for it.
Several browser extensions can also make phone numbers found in webpages clickable.
OSX 10.10 "Yosemite" is required.
4 apps are prebuilt for download in the GitHub release.

If you have a Google Voice number linked to your Hangouts account, incoming calls will popup in the roster.
* press Enter or Space to Accept the call
* press ESC or Backspace to Decline it
## Included Apps

* [Digg.app](http://digg.com/reader)
===
My chosen replacement for Google Reader.
```
# URLs:
feed:http://example.com/sampleblog.xml
rss://example.com/sampleblog.xml
```
#### [Hangouts.app](http://plus.google.com/hangouts): SMS/IM/Video chat client for the desktop
![screenie](/sites/Hangouts/screenshot.jpg?raw=true)
Load up does take up to 30 seconds, so be patient.

If you are surfing a blog in Safari and want to subscribe to it in your Digg Reader account:
* click Safari's Sharing button
* click "Add to Shared Links"
* Answer "No" when prompted to add it your Safari Shared links.
* If Safari found a feed or rss metatag/mime-type, it will be passed to the Digg app which will prompt you to add it to your subscriptions.
* PROTIP: [Add the old RSS button back to Safari 8](http://www.red-sweater.com/blog/2624/subscribe-to-feed-safari-extension)

* [Trello.app](http://trello.com)
===
Mind-mapper and project planner extraordinaire. Pinterest for geeks :-)
![screenie](/sites/Trello/screenshot.jpg?raw=true)
```
URLs:
trello:<search keywords>
```
New incoming messages are shown in OSX's Notification Center,
which you can click on to reply back in the app.

Under [extras/](/sites/Hangouts/extras) you'll find:

* `Call via Hangouts.service`: enables selecting and right-clicking a phone number in any App's text to make a Hangout Call
* `HangoutsAddressBookPlugin`: allows click-to-call from Contacts.app phone number fields

Several browser extensions can also make phone numbers found in webpages clickable.

If you have a Google Voice number linked to your Hangouts account, incoming calls will popup in the App's contacts roster.
Hangouts.app will automatically steal focus so you can quickly answer or reject the call using the keyboard:

* press Enter or Space to accept the call
* press Escape or Backspace to decline it

Custom URLs: [SMS](sms:5558675309) [Call](tel:18001234567) [IM](hangouts:[email protected])


#### [Digg.app](http://digg.com/reader): A replacement for Google Reader

If you are surfing a blog in Safari and want to subscribe to it in your Digg Reader account:

* click Safari's Sharing button
* click "Add to Shared Links"
* Answer "No" when prompted to add it your Safari Shared links.
* If Safari found a feed or rss metatag/mime-type, it will be passed to Digg.app which will prompt you to add it to your subscriptions.
* PROTIP: [Add the old RSS button back to Safari 8](http://www.red-sweater.com/blog/2624/subscribe-to-feed-safari-extension)

Custom URLs: [feed](feed:http://example.com/sampleblog.xml) [rss](rss://example.com/sampleblog.xml)

Opening these urls will pop a tab with a search of your Trello boards and cards for the supplied keywords.
PROTIP: Install Alfred, Quicksilver, or Spotlight to facilitate really fast searches.
#### [Trello.app](http://trello.com): Mind-mapper and project planner
![screenie](/sites/Trello/screenshot.jpg?raw=true)

* [Vine.app](http://vine.co)
===
It shows the mobile version of the site and does not preload any videos,
so you can choose how to spend your bandwidth & time.
#### [Vine.app](http://vine.co): Mobile-layout edition for the desktop

Vine has a webpage now, but it is a grid layout and PRECACHES 100% of ALL OF THE VIDEOS on Safari.
Vine.app shows the mobile layout and does not preload any videos.

Custom URLs: [search your trello for something](trello:search for something)


## Creating an App

Creating an App
====
```
mkdir sites/MySite
vim sites/MySite/app.js
# look at other sites/*/app.js and WebAppScriptExports for available commands
# peruse sites/*/app.js for available commands
make
open apps/MySite.app
# test, tweak, repeat
# test, tweak, lather, repeat
# find a suitable .png or .icns for the app
cp ~/Pictures/MySite.png icons/
# else WebKit.icns will be used
make install
open -a MySite.app
#to customize the icon, find a suitable .png or .icns and place it in icons/ and remake
cp ~/Pictures/MySite.png icons/
```

Develop
===
It's mostly written in Swift using WKWebView and NSTabViewController.
No NIBs, fully programmatic UI layout.
You need Xcode installed on OSX Yosemite to get the Swift compiler and Cocoa headers.
## Hacking the Gibs^H^H^H^HMacPin

It's written in Swift using WKWebView and NSTabViewController.
Fully programmatic NIB-less UI layout. Easy for a single window without any dialogs :-)
You need Xcode installed on OSX Yosemite to get the Swift compiler and Cocoa headers.

```
vim webview.swift
vim execs/MacPin.swift
vim modules/MacPin/*.swift
make test
```
Web Inspector is available in the app, and remote debugging via Safari too when debug= is set in the Makefile.

Check out https://github.com/mozilla/firefox-ios/ to see a another Swift-based browser for iOS.
Web Inspector is available in the app, and remote debugging via Safari too when `debug=` is set in the Makefile.

The JavaScript API is undocumented and unstable, but I think its mostly fleshed out now.

Some browser functionality is unimplementable, partly due to WKWebKit's immaturity:

* File Uploads via File Picker (HTML5 drag & drop is working)
* Geolocation
* Printing
* Favicons

And some things I just haven't had need to write:

* Bookmarks, global history
* Undo/redo tabs


Check out [Firefox for iOS](https://github.com/mozilla/firefox-ios/) to see another Swift-based browser for iOS.
2 changes: 0 additions & 2 deletions modules/WebKitPrivates/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// http://stackoverflow.com/a/24794675/3878712
// http://clang.llvm.org/docs/Modules.html
module WebKitPrivates {
umbrella header "WebKitPrivates.h"
export *
Expand Down
Loading

0 comments on commit a12d002

Please sign in to comment.