summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/commands/site/export.py2
-rw-r--r--frontend/app/site/app.js2
-rw-r--r--frontend/app/site/site/site.actions.js2
-rw-r--r--frontend/app/views/page/components/tile.form.js35
-rw-r--r--frontend/app/views/page/components/tile.handle.js7
-rw-r--r--webpack.config.site.js4
6 files changed, 46 insertions, 6 deletions
diff --git a/cli/commands/site/export.py b/cli/commands/site/export.py
index 5f4636a..0ba6a62 100644
--- a/cli/commands/site/export.py
+++ b/cli/commands/site/export.py
@@ -30,7 +30,7 @@ def cli(ctx, opt_graph_path, opt_output_dir):
return
# build everything here
- graph_dir = join(opt_output_dir, graph.path)
+ graph_dir = os.path.abspath(join(opt_output_dir, graph.path))
# load site index
index_html = load_text(join(app_cfg.DIR_STATIC, 'site.html'), split=False)
diff --git a/frontend/app/site/app.js b/frontend/app/site/app.js
index cf52460..389e5b5 100644
--- a/frontend/app/site/app.js
+++ b/frontend/app/site/app.js
@@ -31,3 +31,5 @@ export default class App extends Component {
)
}
}
+/*
+*/
diff --git a/frontend/app/site/site/site.actions.js b/frontend/app/site/site/site.actions.js
index 2eea442..79e4573 100644
--- a/frontend/app/site/site/site.actions.js
+++ b/frontend/app/site/site/site.actions.js
@@ -1,4 +1,4 @@
-import * as types from 'app/types'
+import * as types from '../types'
import { api } from 'app/utils'
export const setSiteTitle = title => dispatch => {
diff --git a/frontend/app/views/page/components/tile.form.js b/frontend/app/views/page/components/tile.form.js
index 5b25f13..3f43dd0 100644
--- a/frontend/app/views/page/components/tile.form.js
+++ b/frontend/app/views/page/components/tile.form.js
@@ -15,7 +15,7 @@ import { preloadImage } from 'app/utils'
import * as tileActions from '../../tile/tile.actions'
const SELECT_TYPES = [
- "image", "text", "link"
+ "image", "text", "link", "script",
].map(s => ({ name: s, label: s }))
const ALIGNMENTS = [
@@ -33,6 +33,7 @@ const REQUIRED_KEYS = {
image: ['url'],
text: ['content'],
link: [],
+ script: [],
}
const IMAGE_TILE_STYLES = [
@@ -109,6 +110,14 @@ const newLink = (data) => ({
...data,
})
+const newScript = (data) => ({
+ settings: {
+ ...newPosition({ width: 100, height: 100, }),
+ },
+ type: 'script',
+ ...data,
+})
+
const newPosition = (data) => ({
x: 0, y: 0,
width: 0, height: 0,
@@ -122,6 +131,7 @@ const TYPE_CONSTRUCTORS = {
image: newImage,
text: newText,
link: newLink,
+ script: newScript,
}
class TileForm extends Component {
@@ -356,6 +366,8 @@ class TileForm extends Component {
? this.renderTextForm()
: temporaryTile.type === 'link'
? this.renderLinkForm()
+ : temporaryTile.type === 'script'
+ ? this.renderScriptForm()
: ""}
{this.renderHyperlinkForm()}
@@ -555,6 +567,27 @@ class TileForm extends Component {
)
}
+ renderScriptForm() {
+ const { temporaryTile } = this.props
+ const { errorFields } = this.state
+ return (
+ <div>
+ <TextArea
+ title=""
+ name="content"
+ required
+ data={temporaryTile.settings}
+ error={errorFields.has('content')}
+ onChange={this.handleSettingsChange.bind(this)}
+ autoComplete="off"
+ />
+ <div>
+ Scripts will be run on the live site when this page loads.
+ </div>
+ </div>
+ )
+ }
+
renderHyperlinkForm() {
const { temporaryTile } = this.props
const { pageList } = this.state
diff --git a/frontend/app/views/page/components/tile.handle.js b/frontend/app/views/page/components/tile.handle.js
index e91f0b1..624b175 100644
--- a/frontend/app/views/page/components/tile.handle.js
+++ b/frontend/app/views/page/components/tile.handle.js
@@ -66,6 +66,13 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
style.width = tile.settings.width ? tile.settings.width + 'px' : 'auto'
style.height = tile.settings.height ? tile.settings.height + 'px' : 'auto'
break
+ case 'script':
+ content = ""
+ if (viewing) {
+ eval(tile.settings.content)
+ } else {
+ content = "SCRIPT"
+ }
}
if (viewing && tile.href) {
if (tile.href.indexOf('http') === 0) {
diff --git a/webpack.config.site.js b/webpack.config.site.js
index 07a48c8..6416ee9 100644
--- a/webpack.config.site.js
+++ b/webpack.config.site.js
@@ -4,12 +4,10 @@ const webpack = require('webpack')
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
-
-
module.exports = {
mode: "production",
entry: {
- main: './frontend/site/index.js'
+ main: './frontend/app/site/index.js'
},
output: {
path: path.resolve(__dirname, 'static/js/dist'),