fbg13 Posted September 19, 2016 Posted September 19, 2016 File Editor GitHub https://github.com/f-b-g-m/ProcessFileEdit matjazp version https://github.com/matjazpotocnik/ProcessFileEdit A module that allows you to edit file directly in the in the admin area. First module and first time doing a file editor so the way i do it might not be the best. Feedback is welcome. Editor page Setting page 13
szabesz Posted September 19, 2016 Posted September 19, 2016 Normally I locked down such features in any CMS I've used so far, but thanks for sharing anyway.
adrian Posted September 19, 2016 Posted September 19, 2016 Thanks for sharing @fbg13 - just so you know, we already have: http://modules.processwire.com/modules/template-editor/ and there is @tpr's fork which adds module file editing as well: https://github.com/rolandtoth/ProcessTemplateEditor It might be worth trying to consolidate the two modules - I am not sure the feature set of yours vs @Nico Knoll's and @tpr's fork. I know Nico has been quiet around here of late - perhaps you or @tpr could take over with one definitive module for this? 2
tpr Posted September 19, 2016 Posted September 19, 2016 I would be happy if it weren't me - you know, steroids side effects 4
fbg13 Posted September 20, 2016 Author Posted September 20, 2016 12 hours ago, adrian said: Thanks for sharing @fbg13 - just so you know, we already have: http://modules.processwire.com/modules/template-editor/ and there is @tpr's fork which adds module file editing as well: https://github.com/rolandtoth/ProcessTemplateEditor It might be worth trying to consolidate the two modules - I am not sure the feature set of yours vs @Nico Knoll's and @tpr's fork. I know Nico has been quiet around here of late - perhaps you or @tpr could take over with one definitive module for this? I did this mostly to learn how to create a module with settings and a PW admin page. Maybe it would fit better in the Module/Plugin Development sub-forum.
adrian Posted September 20, 2016 Posted September 20, 2016 1 minute ago, fbg13 said: Maybe it would fit better in the Module/Plugin Development sub-forum. I am not saying that at all. Nico is working at an agency these days that is mostly using MeteorJS, so I don't think he has much time to maintain his modules. I just thought it might be worth contacting him and seeing if perhaps you could take over his module, or let us know what advantages yours has over his. We're just all keen on limiting the number of module duplicates that WP suffers with - certainly not trying to diminish your efforts at all - sorry if it came across that way. I wasn't even sure if you knew about his module so it was also a bit of a heads up in that regard. Keep up the great work! 2
fbg13 Posted September 20, 2016 Author Posted September 20, 2016 @adrian I know what you meant. Just that i built this to learn and don't know how much i will further improve this module, that's why maybe the development sub-forum might have been a better fit.
adrian Posted September 20, 2016 Posted September 20, 2016 8 hours ago, fbg13 said: @adrian I know what you meant. Just that i built this to learn and don't know how much i will further improve this module, that's why maybe the development sub-forum might have been a better fit. Honestly it looks like you module might be more complete - you are using a js code editor which would make for a much nicer editing experience and it looks like your use of php file tree also makes for a better interface. I don't think this should be hidden at all - I think I'd rather see it in the modules directory as well as Nico's, rather than being lost. 2
netcarver Posted September 20, 2016 Posted September 20, 2016 @fbg13 Please do add this to the PW modules repository! 1
qtguru Posted October 1, 2016 Posted October 1, 2016 This looks awesome, well I don't think we should limited to 1 Module, different modules might have things that don't appeal to you, with that being said, This will benefit me because I am behind a Firewall at the office, so it's hard to FTP in my site. 1
netcarver Posted October 1, 2016 Posted October 1, 2016 @fbg13 Could you make it so that the edit page is only provided to superusers and maybe users with a certain role such as 'file-editor'? This would allow people like Sephiroth to use your module while keeping other users well away from the files. 1
fbg13 Posted October 1, 2016 Author Posted October 1, 2016 @netcarver i tested the roles and permissions and it looks like until a superuser give another role the "file-editor" permission he can't access the page at all. While testing this i discovered a bug, if the edited file contains the "</textarea>" text it will cause the text-area to close prematurely causing weird output, this is caused by code mirror. Will look into it.
netcarver Posted October 1, 2016 Posted October 1, 2016 2 minutes ago, fbg13 said: i tested the roles and permissions and it looks like until a superuser give another role the "file-editor" permission he can't access the page at all. I think that's a reasonable position to take - it addresses the concern expressed by @szabesz here, and can still be used to provide folks like @Sephiroth access as described here. 1
fbg13 Posted October 3, 2016 Author Posted October 3, 2016 Updated the module to fix the above bug and some other things. Also added options to set a height for the editor, choose whether you want to include or exclude the defined extensions and the default file is now relative to the default directory. 2
fbg13 Posted October 22, 2016 Author Posted October 22, 2016 @matjazp has forked the module with some changes to it.
matjazp Posted October 23, 2016 Posted October 23, 2016 Thanks, @fbg13It's not quit ready for prime time yet, there are some bugs I'm working on, will update here. 1
matjazp Posted October 25, 2016 Posted October 25, 2016 v1.4.0 is at https://github.com/matjazpotocnik/ProcessFileEdit Changes: - removed ProcessWIre namespace, module should work from PW 2.5.5 and up - edit file in modal window 2
matjazp Posted November 5, 2016 Posted November 5, 2016 v1.5.0: - warning about unsaved changes (suggested by tpr) - better wording about include/exclude filter (suggested by tpr) - better visual feedback on Save (suggested by tpr) - theme selection (suggested by tpr) - small speed improvement on directory tree generation - small enhancements and fixes - codemirror update to 5.20.2 Thanks to our "Man on Steroids" 3
tpr Posted November 5, 2016 Posted November 5, 2016 It seems that this *reputation* sticks with me even though I'm clean Nomen est omen? Ontopic: this is a great module, simple and minimal, comes handy for quick modifications when there's no editor or IDE at hand. 2
adrian Posted November 18, 2016 Posted November 18, 2016 Hi everyone, I just installed this for the first time to help debug something on someone's site and thought this would be the easiest way to edit module files without asking for FTP access. It worked great until I saved the file with a syntax error and then needed FTP access to get anything working. This is more of a heads up than anything. Not sure what a workaround might be. Tracy's TemplateEditor Panel allows testing file changes, but this only works for the template file of the current page. Not sure how this could be done for other files - seems unlikely, but I'll have a think. The other thing I wanted to report is that the Setup > Files Editor page is not being created on install. I tested on another PW site and the same thing. Once I manually created it, everything worked fine. 1
matjazp Posted November 19, 2016 Posted November 19, 2016 Hi, adrian! I added a warning to the readme file for next versions, so that everyone should be aware that they need a backup solution in case they cut himself off the admin. I'm not creating the page by myself, I'm letting PW do it for me: $info = array( 'title' => 'Files Editor', 'summary' => _('Edit files'), 'version' => '1.6.3', 'author' => 'Florea Banus George, Matjaž Potočnik, Roland Toth', 'icon' => 'file-o', 'href' => 'https://github.com/matjazpotocnik/ProcessFileEdit/', 'requires' => 'ProcessWire>=2.5.5, PHP>=5.3.8', 'permission' => 'file-editor', 'permissions' => array( 'file-editor' => _('Edit Files (recommended for superuser only)') ), 'page' => array( 'name' => 'file-editor', 'parent' => 'setup', 'title' => 'Files Editor' ), ); @adrian,would you be so kind and PM me, I would appreciate if you could give me more info about your server. 1
fbg13 Posted November 19, 2016 Author Posted November 19, 2016 @matjazp i can confirm the fact that the page is not created, tested on both windows 10 and debian 8 with PW 3.0.40 and PHP 5.6 It worked with version 1.5.4. 1
adrian Posted November 19, 2016 Posted November 19, 2016 1 hour ago, matjazp said: I added a warning to the readme file for next versions, so that everyone should be aware that they need a backup solution in case they cut himself off the admin. Sounds good - I guess it's really only issue if you are editing a file that is an autoload module, or perhaps a hook in something ready.php that is run whenever the admin loads. 1 hour ago, matjazp said: I'm not creating the page by myself, I'm letting PW do it for me: As @fbg13 noted that actually isn't working for some reason. I tried two different servers. As initial glance I am not sure why. I have used that 'page' => array approach successfully myself, although never in a info.php file - I wonder if perhaps that isn't working properly?
matjazp Posted November 19, 2016 Posted November 19, 2016 (edited) It's not working, if the module has it's own install method. I added that in v1.6.1 to check for mbstring and iconv support. To overcome this you have to either remove your own install method or create a page by yourself, like this: public function ___install() { /* try { $this->installPage('file-editor', 'setup', 'Files Editor'); } catch(Exception $e) { $this->error("Can't create a page."); } */ parent::___install(); if(!extension_loaded('mbstring') || !function_exists('iconv')) { $this->message("Support for mbstring and iconv is recommended."); } } Thank you both for the report, v1.6.4 is up & running Edit: I forgot to call parent::___install(); Edited November 19, 2016 by matjazp 1
fbg13 Posted November 19, 2016 Author Posted November 19, 2016 Works now. One suggestion: add a link to the code mirror theme demo page.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now