silverleague / silverleague.github.io

The home of the SilverLeague
http://silverleague.github.io
1 stars 1 forks source link

Proposal: silverstripe-stride #10

Open zanderwar opened 7 years ago

zanderwar commented 7 years ago

silverleague/silverstripe-stride

Why?

Occasionally you may be required to provide a client with a safe way to modify CSS, Javascript and/or .SS template files, but don't want to provide FTP access for example, this module would add a LeftAndMain interface which would scan the /themes/ directory and index the files within which can be then edited directly through the CMS.

The module would be fully permissive, that is if you only wanted to allow the end user to edit CSS, Javascript, and/or Templates etc you could do so via CMS permissions or even a YAML configuration.

Whats the name mean?

Stride is just a play on words and really is just Stripe and IDE conjoined

Details

This module will provide an interface for end-users to modify their theme-related files directly within the CMS

Functionality

Suggestions

robbieaverill commented 7 years ago

What kind of in-browse IDE would we use for this? CodeMirror seems like a pretty common option.

zanderwar commented 7 years ago

I've had great experiences with implementing Ace Editor could put it to a vote

Firesphere commented 7 years ago

Ace looks good

andrewandante commented 7 years ago

I've seen this kind of thing somewhere before. Main concern is that your theme is no longer stored in git. Which is odd.

This is the one I have seen: https://github.com/silverstripe-archive/silverstripe-dynamictemplate

However, I see the use case. +1 for Ace, used it for a Yaml field before. I forked another module:

Original: https://github.com/nathancox/silverstripe-codeeditorfield Mine: https://github.com/andrewandante/silverstripe-codeeditorfield

Need to make that PR. Oops!

zanderwar commented 7 years ago

Thanks for the CodeEditorField, It's been tightly coupled with the POC I'm working on at the moment, have updated it to be compatible with SS4 and cleaned it up quite significantly. Credit is given to the original author(s)

madmatt commented 7 years ago

I don't know that editing files on the filesystem is a good idea. In any multi-server environment this won't work and will end up being inconsistently applied - as well as the issue that then your UAT and production environments are different, and neither of them are built from a common source (version control system).

Even if you you add a system like Drupal Features that make these a bit easier to export and re-apply to other environments I think this isn't the greatest option. At the very least, it needs to be really clear that a template on-disk has been modified.

Perhaps the better option that modifying files in place is to store templates in the database, and allow database templates to override local files if they exist. That way the physical codebase doesn't change, you avoid concurrency/multi-server issues, and as long as it's clear where a template has come from (e.g. adding a URL variable to enable SSViewer.source_file_comments and indicating overridden templates) it would make it easy for developers to figure out why any changes they make aren't working.

Firesphere commented 7 years ago

Perhaps the better option that modifying files in place is to store templates in the database, and allow database templates to override local files if they exist.

I think there's a module that does exactly that. Allowing "inline templates" to be built from given. https://github.com/nyeholt/silverstripe-usertemplates I think does that.

Firesphere commented 7 years ago

Also, in addition to @madmatt his comment. The changes won't reflect in a VCS repository, thus be overwritten on the next deploy, possibly causing frustration, confusion, anger and all kinds of other things.

robbieaverill commented 7 years ago

I think DB based template overrides would make sense. I think this proposal initially was focussing on the "editing templates" more than where to save them, but agree that not editing files on the server is a good plan

Firesphere commented 7 years ago

I would reject in favor of possible DB changes recorded.It is too sensitive and not taking VCS into account.

Further updates fixing this are up for reconsideration of course.

Idea/Concept: Good Execution: Needs some work

robbieaverill commented 7 years ago

It is too sensitive and not taking VCS into account.

I believe the original idea was to let you mock stuff up on the server and export as a diff patch (takes VCS into account).

I don't see much point in rejecting a proposal that's in progress - we should just amend the scope to say "it should store modified templates in the DB" and "it should use DB templates in a higher priority than those in the template manifest where they exist"

Firesphere commented 7 years ago

Valid. Agreed on that.

What does concern me however, is still VCS. If a template changes, but is loaded from DB because DB overrides actual templates, confusion/anger etc. may still occur. For me to agree I would need a way to set that straight.

robbieaverill commented 7 years ago

That's a good point - perhaps the DB record needs to store the object hash that it was based from so we can compare in say a GridField view of DB templates and notify the user when it has diverged from the source.

Firesphere commented 7 years ago

That would cover most of it. But that's a "probably", not a "yep, would do". I'd like to hear @zanderwar his thoughts on the issue at hand?

zanderwar commented 7 years ago

Yes, altering files directly was always a frowned upon approach, however regarding this module, the working POC would do exactly that and then promptly move to a versioning based/DB system instead.

Even which I'd imagine it'd be a mix of DB storage and direct file manipulation, where the original would always be stored in DB along with any subsequent versions. The file itself would always have the latest version and we can just opt to call dev/build?flush=1 functionality rather than integrating our own methodology to override templates albeit looks simple enough given the usertemplates module linked above. (Could even go as far as file based versioning system)

I'd imagine irregardless the module would need to be shipped "at your own risk" as this module is intended for the dev-savvy, not the average content editor.

Which reminds me, I need to get that POC out :1st_place_medal:

robbieaverill commented 6 years ago

I'm guessing this lost traction - is anyone still keen on getting it going?

robbieaverill commented 6 years ago

There's some similar movement in this area here: https://github.com/mikenz/silverstripe-codeeditorfield

robbieaverill commented 5 years ago

Also not the same, but similar enough to be worth pointing out: https://github.com/tractorcow/web-console

cc @andrewandante @zanderwar - if you guys aren't keen to get this going I think we'll close it in the next couple of weeks

andrewandante commented 5 years ago

My SilverStripe dev time has plummeted of late for obvious reasons. I'm not going to be able to kick it off.

robbieaverill commented 5 years ago

@andrewandante no worries. @zanderwar still keen? Let's close it if not