Skip to content

Commit

Permalink
Merge pull request #16 from MichaelBuessemeyer/pretty-smalltalk
Browse files Browse the repository at this point in the history
  • Loading branch information
cmfcmf authored Feb 19, 2022
2 parents b42c84b + d41c6f5 commit 14f2288
Show file tree
Hide file tree
Showing 91 changed files with 448 additions and 409 deletions.
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<img src="logo/magicmouse.png" alt="MagicMouse Logo" width="120" height="120"> MagicMouse Webbrowser
==================
# <img src="logo/magicmouse.png" alt="MagicMouse Logo" width="120" height="120"> MagicMouse Webbrowser

[![Tests](https://github.com/cmfcmf/MagicMouse/actions/workflows/tests.yml/badge.svg)](https://github.com/cmfcmf/MagicMouse/actions/workflows/tests.yml)
[![Build Node.js Binaries](https://github.com/cmfcmf/MagicMouse/actions/workflows/build-node-binaries.yml/badge.svg)](https://github.com/cmfcmf/MagicMouse/actions/workflows/build-node-binaries.yml)
Expand All @@ -8,9 +7,9 @@ MagicMouse is a webbrowser for [Squeak](https://squeak.org). It uses Chrome/Chro

MagicMouse runs on all platforms that run Squeak and Chrome, but works best and is most tested on Windows.

| | |
|-|-|
| ![Screenshot of Google](images/google.png) | ![Screenshot of YouTube](images/youtube.png) |
| | |
| ---------------------------------------------- | ------------------------------------------------- |
| ![Screenshot of Google](images/google.png) | ![Screenshot of YouTube](images/youtube.png) |
| ![Screenshot of SqueakJS](images/squeakjs.png) | ![Screenshot of Lively Kernel](images/lively.png) |

## Features
Expand All @@ -23,7 +22,7 @@ MagicMouse runs on all platforms that run Squeak and Chrome, but works best and
- If you start your search with `!s `, your search terms are used to search https://squeak.org.
- `CTRL+L` toggles fullscreen.
- Dropped texts are typed into form fields.
- *browseIt* any URL to open it in a browser.
- _browseIt_ any URL to open it in a browser.
- Rick roll yourself! Send `rickRoll` to your favourite class or object to get started.
- Open browsers reconnect after resuming Squeak.
- Create and browse bookmarks.
Expand All @@ -45,11 +44,12 @@ MagicMouse runs on all platforms that run Squeak and Chrome, but works best and
1. Install a recent version of Chrome or Chromium. MagicMouse uses the Chrome DevTools protocol to communicate with the browser and relies on the newish and experimental [`startScreencast`](https://chromedevtools.github.io/devtools-protocol/tot/Page#method-startScreencast) functionality. Chrome 76 works for me.
2. Install Squeak 5.2+ (you probably have that already :D).
3. Install MagicMouse via Metacello.

```smalltalk
Metacello new
baseline: 'MagicMouse';
repository: 'github://cmfcmf/MagicMouse:master/packages';
load.
baseline: 'MagicMouse';
repository: 'github://cmfcmf/MagicMouse:master/packages';
load.
```

You will be prompted to download a binary that acts as a bridge between Squeak and Chrome. See the `MMPluginDownloader` for details. Binaries are stored at [Bintray](https://bintray.com/cmfcmf/MagicMouse/node-bridge/latest?tab=files#files/).
Expand Down Expand Up @@ -129,3 +129,25 @@ The installation is a bit cumbersome at the moment:
- Change the `Git Repository Path` in the MagicMouse category to match the location of the cloned repository.
- Check the `Do not use prebuilt binary` option.
- You probably also want to enable the `Enable debug` property to log debug output to the Transcript.

## Contributing

Your contribution to this project is highly appreciated. If you are contributing to this project please note that the Smalltalk / Squeak part of the project uses the [poppy-print](https://github.com/hpi-swa-teaching/poppy-print) code formatter by @tom95.

To install this formatter execute

```smalltalk
Metacello new baseline: 'PoppyPrint'; repository: 'github://tom95/poppy-print/packages'; load.
```

in a workspace. Then the following can be used to format the smalltalk code:

```smalltalk
PPFormatter formatPackage: 'MagicMouse'.
```

The nodejs part of the project also has a formatter called prettier. Additionally, it is linted via eslint.

To format and lint the code with automated fixing use `yarn format`.

Please make sure that all your submitted code is formatted with the given formatters and that the nodejs part is linted, before merging your contribution.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
building
buildButtonBarWith: aBuilder

^ {aBuilder pluggableButtonSpec new
^ {
aBuilder pluggableButtonSpec new
model: self;
action: #showBookmarks;
label: 'Bookmarks';
yourself.
aBuilder pluggableButtonSpec new
model: self;
action: [(PreferenceBrowser open) selectedCategory: #MagicMouse];
action: [PreferenceBrowser open selectedCategory: #MagicMouse];
label: 'Preferences';
yourself.
}
yourself}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildTopBarWith: aBuilder

^ {
aBuilder pluggableButtonSpec new
frame: ((LayoutFrame fractions: (0@0 extent: 0@1))
frame: ((LayoutFrame fractions: (0 @ 0 extent: 0 @ 1))
rightOffset: 25;
yourself);
model: self;
Expand All @@ -12,7 +12,7 @@ buildTopBarWith: aBuilder
label: '<';
yourself.
aBuilder pluggableButtonSpec new
frame: ((LayoutFrame fractions: (0@0 extent: 0@1))
frame: ((LayoutFrame fractions: (0 @ 0 extent: 0 @ 1))
leftOffset: 25;
rightOffset: 50;
yourself);
Expand All @@ -21,21 +21,21 @@ buildTopBarWith: aBuilder
action: [browser goForward];
label: '>';
yourself.
aBuilder pluggableInputFieldSpec new
aBuilder pluggableInputFieldSpec new
model: self;
hardLineWrap: false;
softLineWrap: false;
getText: #locationText;
setText: #changeLocation:;
askBeforeDiscardingEdits: false;
help: 'Location';
frame: ((LayoutFrame fractions: (0@0 extent: 0.8@1))
frame: ((LayoutFrame fractions: (0 @ 0 extent: 0.8 @ 1))
leftOffset: 50;
rightOffset: -50;
yourself);
yourself.
aBuilder pluggableButtonSpec new
frame: ((LayoutFrame fractions: (0.8@0 corner: 0.8@1))
frame: ((LayoutFrame fractions: (0.8 @ 0 corner: 0.8 @ 1))
leftOffset: -50;
rightOffset: -25;
yourself);
Expand All @@ -46,21 +46,21 @@ buildTopBarWith: aBuilder
help: 'bookmark';
yourself.
aBuilder pluggableButtonSpec new
frame: ((LayoutFrame fractions: (0.8@0 corner: 0.8@1))
frame: ((LayoutFrame fractions: (0.8 @ 0 corner: 0.8 @ 1))
leftOffset: -25;
yourself);
model: self;
label: 'R';
action: [browser doRefresh];
help: 'refresh';
yourself.
aBuilder pluggableInputFieldSpec new
aBuilder pluggableInputFieldSpec new
model: self;
hardLineWrap: false;
softLineWrap: false;
getText: #searchText;
setText: #searchFor:;
askBeforeDiscardingEdits: false;
help: 'Search with Google';
frame: (LayoutFrame fractions: (0.8@0 extent: 0.2@1));
frame: (LayoutFrame fractions: (0.8 @ 0 extent: 0.2 @ 1));
yourself}
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
building
buildWith: aBuilder

^ aBuilder build: (aBuilder pluggableWindowSpec new
label: MMBrowserMorph title;
extent: 600@400;
model: self;
children: {
aBuilder pluggablePanelSpec new
wantsResizeHandles: true;
frame: (LayoutFrame fractions: (0@0 extent: 1@0) offsets: ((0@0) extent: (0@ 25)));
children: (self buildTopBarWith: aBuilder);
yourself.
aBuilder pluggablePanelSpec new
frame: (LayoutFrame fractions: (0@0 extent: 1@0) offsets: ((0@25) extent: (0@ 25)));
layout: #horizontal;
children: (self buildButtonBarWith: aBuilder);
yourself.
aBuilder pluggablePanelSpec new
wantsResizeHandles: true;
frame: (LayoutFrame fractions: (0@0 extent: 1@1)
offsets: (0@50 extent: (0@ -50)));
spacing: 5;
children: {
aBuilder pluggablePanelSpec new
model: self;
frame: (0@0 extent: 0.8@1);
children: #getBrowserMorph;
yourself.
aBuilder pluggableListSpec new
model: self;
frame: (0.8@0 corner: 1@1);
list: #extractedObjects;
doubleClick: #exploreExtractedObject;
getSelected: #selectedExtractedObject;
setSelected: #selectedExtractedObject:;
dragItem: #dragExtractedObject:;
yourself
};
yourself.
};
yourself)

^ aBuilder build: (aBuilder pluggableWindowSpec new
label: MMBrowserMorph title;
extent: 600 @ 400;
model: self;
children: {
aBuilder pluggablePanelSpec new
wantsResizeHandles: true;
frame: (LayoutFrame fractions: (0 @ 0 extent: 1 @ 0) offsets: (0 @ 0 extent: 0 @ 25));
children: (self buildTopBarWith: aBuilder);
yourself.
aBuilder pluggablePanelSpec new
frame: (LayoutFrame fractions: (0 @ 0 extent: 1 @ 0) offsets: (0 @ 25 extent: 0 @ 25));
layout: #horizontal;
children: (self buildButtonBarWith: aBuilder);
yourself.
aBuilder pluggablePanelSpec new
wantsResizeHandles: true;
frame: (LayoutFrame fractions: (0 @ 0 extent: 1 @ 1) offsets: (0 @ 50 extent: 0 @ -50));
spacing: 5;
children: {
aBuilder pluggablePanelSpec new
model: self;
frame: (0 @ 0 extent: 0.8 @ 1);
children: #getBrowserMorph;
yourself.
aBuilder pluggableListSpec new
model: self;
frame: (0.8 @ 0 corner: 1 @ 1);
list: #extractedObjects;
doubleClick: #exploreExtractedObject;
getSelected: #selectedExtractedObject;
setSelected: #selectedExtractedObject:;
dragItem: #dragExtractedObject:;
yourself};
yourself};
yourself)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ dragExtractedObject: aNumber
| domainObject |
domainObject := extractedObjects at: aNumber.
domainObject undelete.

^ domainObject
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ building
getBrowserMorph

browser isConnected ifFalse: [
browser connect: self locationText.
browser layoutFrame: (LayoutFrame fractions: (0@0 extent: 1@1)).
browser connect: self locationText.
browser layoutFrame: (LayoutFrame fractions: (0 @ 0 extent: 1 @ 1)).
browser when: #locationChanged send: #locationText: to: self.
browser when: #structuredDataChanged send: #structuredDataChanged: to: self].
^ { browser }
^ {browser}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ initialize
locationText := 'https://google.com'.
searchText := ''.
browser := MMBrowserMorph new.
extractedObjects := OrderedCollection new.
extractedObjects := OrderedCollection new
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ locationText: aText

| url |
url := aText asString.
((url findString: 'https://') = 0 and: [(url findString: 'http://') = 0]) ifTrue: [
url := 'https://', url].
((url findString: 'https://') = 0 and: [(url findString: 'http://') = 0]) ifTrue: [url := 'https://', url].
locationText := url.
self changed: #locationText.
self changed: #bookmarkButtonState
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ structuredDataChanged: data
domainObject := Smalltalk classNamed: #DomainObject.
domainObject ifNil: [^ self].

objects := (data collect: [:each | | object |
objects := data collect: [:each | | object |
object := domainObject new delete.
each associationsDo: [:assoc | | field |
field := assoc key asLegalSelector asSymbol.
field = #name ifTrue: [field := #title].
object perform: field asMutator with: assoc value].
object]).
object].
objects ifEmpty: [
objects := {domainObject new delete
title: self locationText asString;
url: self locationText asString;
yourself}].
self extractedObjects: objects.
objects := {
domainObject new delete
title: self locationText asString;
url: self locationText asString;
yourself}].
self extractedObjects: objects
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
"addOrRemoveBookmark" : "cmfcmf 7/7/2019 11:40",
"bookmarkButtonState" : "cmfcmf 7/7/2019 11:38",
"bookmarks" : "cmfcmf 7/7/2019 11:35",
"buildButtonBarWith:" : "cmfcmf 7/7/2019 11:33",
"buildTopBarWith:" : "cmfcmf 7/7/2019 11:39",
"buildWith:" : "cmfcmf 7/7/2019 11:22",
"buildButtonBarWith:" : "MB 1/30/2022 10:33",
"buildTopBarWith:" : "MB 1/30/2022 10:33",
"buildWith:" : "MB 1/30/2022 10:33",
"changeLocation:" : "cf 5/17/2019 09:19",
"dragExtractedObject:" : "cmfcmf 7/7/2019 19:45",
"dragExtractedObject:" : "MB 1/30/2022 10:33",
"exploreExtractedObject" : "cmfcmf 6/11/2019 09:24",
"extractedObjects" : "cmfcmf 6/11/2019 08:54",
"extractedObjects:" : "cmfcmf 6/11/2019 08:55",
"fullscreen:" : "cmfcmf 6/30/2019 17:35",
"getBrowserMorph" : "cmfcmf 8/3/2019 19:13",
"initialize" : "cmfcmf 8/3/2019 19:13",
"getBrowserMorph" : "MB 1/30/2022 10:33",
"initialize" : "MB 1/30/2022 10:33",
"locationText" : "cf 5/1/2019 15:47",
"locationText:" : "cmfcmf 8/3/2019 19:12",
"locationText:" : "MB 1/30/2022 10:33",
"searchFor:" : "cf 5/27/2019 21:35",
"searchText" : "cf 5/1/2019 15:47",
"searchText:" : "cf 5/1/2019 15:58",
"selectedExtractedObject" : "cmfcmf 6/11/2019 09:06",
"selectedExtractedObject:" : "cmfcmf 6/11/2019 09:06",
"showBookmarks" : "cmfcmf 7/7/2019 11:37",
"structuredDataChanged:" : "cmfcmf 8/3/2019 14:44" } }
"structuredDataChanged:" : "MB 1/30/2022 10:33" } }
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
preferences
chromeProfilePath
<preference: 'Chrome profile path' category: 'MagicMouse' description: 'The path to the folder to store the Chrome user profile in. You can leave this empty to store it in your Squeak folder.' type: #String>

<preference: 'Chrome profile path'
category: 'MagicMouse'
description: 'The path to the folder to store the Chrome user profile in. You can leave this empty to store it in your Squeak folder.'
type: #String>
^ ChromeProfilePath ifNil: [(FileDirectory default / 'chromeUserDir') name]
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
preferences
debugEnabled
<preference: 'Debug to Transcript' category: 'MagicMouse' description: 'Print debug output to the Transcript' type: #Boolean>

<preference: 'Debug to Transcript'
category: 'MagicMouse'
description: 'Print debug output to the Transcript'
type: #Boolean>
^ DebugEnabled ifNil: [false]
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
preferences
debugNodejs
<preference: 'Debug Node.js' category: 'MagicMouse' description: 'ONLY FOR DEVELOPMENT. Start Node.js with the --inspect argument' type: #Boolean>

<preference: 'Debug Node.js'
category: 'MagicMouse'
description: 'ONLY FOR DEVELOPMENT. Start Node.js with the --inspect argument'
type: #Boolean>
^ DebugNodejs ifNil: [false]
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
preferences
doNotUsePrebuiltBinary
<preference: 'Do not use prebuilt binary' category: 'MagicMouse' description: 'ONLY FOR DEVELOPMENT. If checked, will call the run.js script directly instead of using the prebuilt binaries.' type: #Boolean>

<preference: 'Do not use prebuilt binary'
category: 'MagicMouse'
description: 'ONLY FOR DEVELOPMENT. If checked, will call the run.js script directly instead of using the prebuilt binaries.'
type: #Boolean>
^ DoNotUsePrebuiltBinary ifNil: [false]
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
preferences
gitRepositoryPath
<preference: 'Git Repository Path' category: 'MagicMouse' description: 'ONLY FOR DEVELOPMENT. The path to the git repository that contains the run.js file and node_modules folder. You may NOT use the repository checked out by the Git Browser, but need to use a separate copy.' type: #String>

<preference: 'Git Repository Path'
category: 'MagicMouse'
description: 'ONLY FOR DEVELOPMENT. The path to the git repository that contains the run.js file and node_modules folder. You may NOT use the repository checked out by the Git Browser, but need to use a separate copy.'
type: #String>
^ GitRepositoryPath ifNil: ['.']
Loading

0 comments on commit 14f2288

Please sign in to comment.