Skip to content
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

zineos #71

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Drop = require "./drop"
GridGen = require "grid-gen"
Notifications = require "./notifications"
Postmaster = require "postmaster"
RemoteInterface = require "./remote-interface"
Tools = require "./tools"
Undo = require "undo"

Expand Down Expand Up @@ -44,7 +45,7 @@ module.exports = (I={}, self=Model(I)) ->
self.include Undo
self.include Tools

Postmaster(self)
self.include RemoteInterface

activeTool = self.activeTool

Expand Down
9 changes: 4 additions & 5 deletions main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ launch = ->
editorElement = Template editor
document.body.appendChild editorElement

try
editor.invokeRemote "childLoaded"
editor.invokeRemote? "childLoaded"

updateViewportCentering = ->
{height: mainHeight, width: mainWidth} = editorElement.querySelector(".main").getBoundingClientRect()
Expand All @@ -29,9 +28,9 @@ if PACKAGE.name is "ROOT"
global.PACKAGE = PACKAGE
global.require = require

runtime = require("runtime")(PACKAGE)
runtime.boot()
runtime.applyStyleSheet(require('./style'))
styleNode = document.createElement("style")
styleNode.innerHTML = require('./style')
document.head.appendChild(styleNode)

metaTag = document.createElement('meta')
metaTag.name = "viewport"
Expand Down
3 changes: 1 addition & 2 deletions pixie.cson
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ dependencies:
matrix: "distri/matrix:v0.3.1"
observable: "distri/observable:v0.3.7"
point: "distri/point:v0.2.0"
postmaster: "distri/postmaster:v0.5.2"
runtime: "distri/runtime:v0.3.0"
postmaster: "distri/postmaster:v0.5.3"
size: "distri/size:v0.1.4"
"touch-canvas": "distri/touch-canvas:v0.4.2"
"undo": "distri/undo:v0.2.0"
Expand Down
18 changes: 18 additions & 0 deletions remote-interface.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = (I, self) ->
# Embedded package in ZineOS
if system? and postmaster?
console.info "Attached ZineOS remote delegate"
self.invokeRemote = postmaster.invokeRemote
postmaster.delegate = self
else if window.location.origin is "null"
# Assume we're in a secure enough embedded iframe
console.info "Attached remote interface"
localPostmaster = require("postmaster")(self)
else if window is window.parent
# Not embedded, no need to enable remote interface
console.info "Not embedded, no remote interface"
else
# otherwise we can't allow the remote interface as it could enable XSS
console.warn "Remote interface disabled, iframe must be sandboxed"

return self
4 changes: 3 additions & 1 deletion style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ body
width: 100%


.editor
editor
background-color: #AAA
box-sizing: border-box
display: block
height: 100%
line-height: initial
padding: 0px 50px 64px 35px
position: relative
user-select: none
Expand Down
58 changes: 0 additions & 58 deletions templates/editor.haml.md

This file was deleted.

48 changes: 48 additions & 0 deletions templates/editor.jadelet
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- activeIndex = @activeIndex
- activeTool = @activeTool
- previousTool = @previousTool
- editor = this
- Symmetry = require "../symmetry"

- Action = require "./action"
- ActionPresenter = require "../presenters/action"
- Palette = require "./palette"
- Tool = require "./tool"
- ToolPresenter = require "../presenters/tool"

editor(class=@loadingClass)
.toolbar
.tools
- @tools.each (tool) ->
= Tool ToolPresenter(editor, tool)
h2 Symmetry
.tools
- symmetryMode = @symmetryMode
- ["normal", "flip", "flop", "quad"].forEach (mode) ->
- activeClass = -> "active" if mode is symmetryMode()
- activate = -> symmetryMode(mode)
.tool(style="background-image: url(#{Symmetry.icon[mode]})" class=activeClass click=activate)

.main
.viewport(style=@viewportStyle class=@viewportCenter class=@viewportChecker)
.overlay(style=@gridStyle)
= @canvas.element()
= @previewCanvas.element()
.thumbnail(click=@thumbnailClick)
= @thumbnailCanvas.element()

.position
= @positionDisplay

.notifications
- @notifications.forEach (notification) ->
p= notification

= Palette(this)

.actions
- @actions.forEach (action) ->
= Action ActionPresenter action, editor

#loader
progress.vertical-center(value=@loadingProgress)