Jump to content

File Editor


fbg13
 Share

Recommended Posts

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?

  • Like 2
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

  • Like 2
Link to comment
Share on other sites

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.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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. 

  • Like 1
Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

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" :-)

  • Like 3
Link to comment
Share on other sites

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.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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.

  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by matjazp
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...