rasmusbergpalm / jslate

Write your dashboards in pure html/js
jslate.com
244 stars 54 forks source link

Use templates by default #52

Closed ghost closed 7 years ago

ghost commented 10 years ago

Great bit of kit, built a custom widget to get json object and display table, works great. Only thing is instead of being able to edit it, I would like it to just use the default widget bla.html file, once you have added a widget it doesn't use this its like a cached editable version. Is there a simple way to get it to just use the template and not be editable, if I can get this sorted I am well up for contributing some of the widgets I am going to build. thanks again

rasmusbergpalm commented 10 years ago

I'm not sure I understand. Do you want to be able to use a previously created widget as a template for new widgets? That's actually not a bad idea! I'd like to see a pull request for that. A MVP of the feature could be that the templates page simply displayed all your widgets as well as the hardcoded templates.

ghost commented 10 years ago

Not really, I think you create a template in the templates folder, like clock.html, that creates the widget on the dashboard, but if I then edit the clock.html it doesnt reflect in the widget on the dashboard. I'd like it to. Instead it looks like you have a copy of it which you can edit. I'm a web developer so happy to learn a bit of cake php to help build this if you can advise me that this isnt possible yet? Thanks

rasmusbergpalm commented 10 years ago

Ah. Yes, the templates are templates, and the widgets are copies of the templates. I'm not sure editing the templates, and having that overwrite the widgets are a good idea. Why would you want that?

ghost commented 10 years ago

I'd just like the copies stored as files not in database, so I can manage as code, make sense not to have the template cascade through but be nice to have the copies in a file rather than db. How tricky would that be to build? Do I need to swallow a cakephp book?

rasmusbergpalm commented 10 years ago

Aha. Hmm. It shouldn't be that hard. Create a folder app/widgets Implement afterSave (maybe beforeSave) in Dbviews.php (see http://book.cakephp.org/2.0/en/models/callback-methods.html) and put the widget code into a file named by the id of the widget into the app/widgets folder (so widget 123 will become saved in app/widgets/123.html ) Implement afterFind in Dbviews.php to load the code from the file and populate the code field of each widget.

On Wed, Dec 4, 2013 at 2:08 PM, zarexogre notifications@github.com wrote:

I'd just like the copies stored as files not in database, so I can manage as code, make sense not to have the template cascade through but be nice to have the copies in a file rather than db. How tricky would that be to build? Do I need to swallow a cakephp book?

— Reply to this email directly or view it on GitHubhttps://github.com/rasmusbergpalm/jslate/issues/52#issuecomment-29802945 .

ghost commented 10 years ago

Great I will pull a fork and add this in as soon as I get a chance. Thanks

ghost commented 10 years ago

I've done that works well, any ideas how I could have the templates be php files instead of html?

ghost commented 10 years ago

I figured this out just add .php to the tempaltes allowed and eval php code sorted thanks

rasmusbergpalm commented 10 years ago

But I don't want them to be php code... That'd allow people to execute arbitrary logic on the server.

On Wed, Dec 4, 2013 at 5:35 PM, zarexogre notifications@github.com wrote:

I figured this out just add .php to the tempaltes allowed and eval php code sorted thanks

— Reply to this email directly or view it on GitHubhttps://github.com/rasmusbergpalm/jslate/issues/52#issuecomment-29820925 .

ghost commented 10 years ago

Thats fine I'm not commiting my changes to this project so it wont effect you. Great work, got some nice stuff working now thanks.

rasmusbergpalm commented 10 years ago

ok

On Wed, Dec 4, 2013 at 7:20 PM, zarexogre notifications@github.com wrote:

Thats fine I'm not commiting my changes to this project so it wont effect you. Great work, got some nice stuff working now thanks.

— Reply to this email directly or view it on GitHubhttps://github.com/rasmusbergpalm/jslate/issues/52#issuecomment-29830387 .