kongondo

Sites Manager (ProcessSitesManager)

Recommended Posts

Sites Manager

 

16 September 2018:

FOR NOW, PLEASE DO NOT USE THIS MODULE IN A PRODUCTION SITE. A  RECENT ProcessWire UPDATE HAS BROKEN THE MODULE. I AM WORKING ON A FIX.

 

################

 

Sites Manager is a module for ProcessWire that allows Superusers to easily create/install ProcessWire sites on the same serverspace the module is running in. Only Superusers can use the module. You can create both stand-alone and multi-sites.

 

Single/Stand-alone Sites

Stand-alone or single-sites are sites that will run in their own document root/directory with their own wire and site folders, .htaccess, index.php, etc. In other words, a normal ProcessWire site.

Multiple Sites

Multi-sites are sites that will run off one wire folder (shared amongst two or more sites) each having their own site folder and database. In this regard, it is important to note that Sites Manager is not in itself a multiple sites solution! Rather, it is a utility that helps you create multi-sites to be run using the ProcessWire core multiple sites feature. For more on this core feature, see the official ProcessWire documentation, specifically the solution referred to as Option #1.

Option #1 approach requires the site admin to initially install ProcessWire in a temporary directory for each new site. The directory then needs to be renamed as site-xxx, where ‘xxx’ is any name you want to use to differentiate the installation from other sites, before it is moved to the webroot. For instance, site-mysite, site-another, site-whatever. In addition, the /wire/index.config.php file must be copied/moved to the webroot. Each time a site is added, the index.config.php has to be edited to add ‘domain’ => ‘site-directory’ key=>value pairs for the site. This process can become a bit tedious. This module aims to automate the whole multi-site site creation process.

The module is based off the official ProcessWire installer. Creating a site is as simple as completing and submitting a single form! You also have the option to type and paste values or reuse a pre-defined install configuration.

 

The module will:

  • Install a ProcessWire site in your named directory, applying chmod values as specified

  • Move the directory to your webroot

  • Update/Create a Superuser account as per the submitted form, including setting the desired admin theme and colour

  • For multi sites, update sites.json (used by index.config.php to get array of installed sites)

 

For multi sites, the only difference in relation to the core multi-sites index.config.php is that this file is slightly different from the one that ships with ProcessWire.

Download from GitHub: Sites Manager (Beta Release)

Features

  1. Install unlimited number of sites in one (multi-sites) or independent (single-site) ProcessWire installs.
  2. Install by completing a Form, Typing or pasting in configurations or using pre-created install configurations.
  3. Choose an Admin Theme to auto-install along with the site installation.
  4. For single-sites installation, download, save and reuse ProcessWire versions of your choice.
  5. Install and maintain site profiles for reuse to create other sites.
  6. Create install configurations to speed up installation tasks.
  7. Client and server-side validation of site creation values.
  8. Edit uploaded profiles (e.g., replace profile file).
  9. Lock installed sites, configurations and profiles to prevent editing.
  10. Bulk delete items such as site profiles, installed site directories and/or databases (confirmation required for latter two).
  11. View important site details (admin login, chmod, etc).
  12. Links to installed sites home and admin pages.
  13. Timezones auto-complete/-suggest.

Pre-requisites, Installation & Usage

Please see the documentation.

Technicalities/Issues

  • Only Superusers can use the module.

  • ProcessWire 2.7 - 3.x compatible

  • Currently using ProcessWire 2.7 installer (install.php)

  • For multi-sites, potential race condition when sites.json is being updated on a new site install vs. index.config.php accessing the json file?

  • Not tested with sub-directory installs (for instance localhost/pw/my-site-here/)

  • Currently not doing the extra/experimental database stuff (database charset and engine)

Future Possibilities

  • Install specified modules along with the ProcessWire install

  • Profile previews?

Credits

  1. @ryan: for the ProcessWire installer

  2. @abdus: for the index.config.php reading from JSON idea

  3. @swampmusic: for the challenge

Video Demo

Demo  showing how quick module works on a remote server [YMMV!]. Video shows downloading and processing two versions of ProcessWire (~takes 7 seconds) and installing a single/stand-alone ProcessWire 3 site using the new Admin Theme UI Kit (~2 seconds) on a remote server.

 

Screens

1

sites-manager-001.thumb.png.114a764e0d801f4c367d037147dbd552.png

2

sites-manager-002.thumb.png.f1b6f75cf5dcb2df9661a0f21664baca.png

 

 
  • Like 18

Share this post


Link to post
Share on other sites

Looks great! Makes me eager to set up a multisite :)

  • Like 1

Share this post


Link to post
Share on other sites

Really cool project. I am used to developing individual sites that with separate wire directories but it gets tedious to update each and every one of them, and not to mention duplicate /wire/ directories. I was thinking of moving to the official multi-site solution, but I'll start with your module. Thanks for sharing it with us.

50 minutes ago, kongondo said:

index.config.php reading from JSON idea

Although for simple configurations this may not matter, I've found out that using PHP files for configuration files are much easier to handle, and doesn't need parsing at all. It's as simple as this:

<?php // mysite.config.php

return [
    'site' => 'mysite',
    'domain' => 'mysite.com'
];

<?php // ConfigReader.php

$configs = [];
foreach(configFiles in configDir) {
    $configs[] = include(configFile);
}

https://github.com/mrkrstphr/array-config

To export as php configuration files you can use

http://php.net/manual/en/function.var-export.php

Major disadvantage is that it's php only whereas JSON is almost universal.

 

  • Like 5

Share this post


Link to post
Share on other sites

Cool stuff!

The profiles you mention: are they a different format from the profiles produced by ProcessExportProfile?

Just wondering because you said...

51 minutes ago, kongondo said:

Future Possibilities

  • Install specified modules along with the ProcessWire install

...but site profiles from ProcessExportProfile can include modules, so wasn't sure.

  • Like 2

Share this post


Link to post
Share on other sites
2 hours ago, abdus said:

but it gets tedious to update each and every one of them

so why do you do that? ;)

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, Robin S said:

The profiles you mention: are they a different format from the profiles produced by ProcessExportProfile?

Just wondering because you said...

...but site profiles from ProcessExportProfile can include modules, so wasn't sure.

No, they are not different. I have not used ProcessExportProfile (but I've been thinking, how nice we have it; it will play nicely with ProcessMultiSites). I assume though that it exports the same type of profiles that ship with ProcessWire (the site-default, etc). so it should work.

What I meant is that, say, you have a blank profile. You want to use that to install several sites. Those sites have different module needs. When creating a site you will be able to paste or select module class names to fetch (live) and install along with the site creation. I haven't thought it through properly and it would mean a delay while the modules are being downloaded.  

Edited by kongondo
  • Like 3

Share this post


Link to post
Share on other sites
4 minutes ago, kongondo said:

What I meant is that, say, you have a blank profile. You want to use that to install several sites. Those sites have different module needs. When creating a site you will be able to paste or select module class names to fetch (live) and install along with the site creation. I haven't thought it through properly and it would mean a delay while the modules are being downloaded.  

exactly what i was talking about here: 

 

see also @abdus comment on top of page2

i don't like site profiles. i think they are far too unflexible mostly because of the reason kongondo said. a possibility to define modules that get installed by default would be great! maybe this module could be extended to a kind of advanced PW installation kit? for example it could also be nice to use it to install a single-site setup in a different directory on the server (in other words, having the possibility to choose wheter the new site should be installed as single or as multisite).

it would also be easy to choose the core version to use for single-site setups by defining the URL like this: https://github.com/processwire/processwire/archive/3.0.36.zip or that https://github.com/ryancramerdesign/ProcessWire/archive/2.7.2.zip

thanks for creating and sharing this module with us kongondo!

  • Like 3

Share this post


Link to post
Share on other sites
1 hour ago, bernhard said:

i don't like site profiles. i think they are far too unflexible

They ARE useful though ;) Think of them as the simplest way of SHARING a site – as a starting point – with the community and it is also needed by the PW installer. No more, no less. Great feature! :D

  • Like 1

Share this post


Link to post
Share on other sites

@kongondo,

It was a joy to wake up and see this effort you have undertaken!  Good luck on making this work.

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, bernhard said:

for example it could also be nice to use it to install a single-site setup in a different directory on the server (in other words, having the possibility to choose wheter the new site should be installed as single or as multisite).

Yeah, I had similar thoughts when drafting the module. This is quite easy to accomplish. Actually, one other reason the module is alpha is that it could end up being more than a multi site thingy, hence I would need to change the Class name. 

3 hours ago, bernhard said:

it would also be easy to choose the core version to use for single-site setups by defining the URL like this: https://github.com/processwire/processwire/archive/3.0.36.zip or that https://github.com/ryancramerdesign/ProcessWire/archive/2.7.2.zip

Cool idea. I'll have a think.

  • Like 2

Share this post


Link to post
Share on other sites

great to hear that :)

hm... what do you think of splitting it into 3 parts:

  1. some kind of advanced pw-installer
  2. a process module to handle multisite installations
  3. a single php file that grabs the pw-installer similar to the online installer from soma (https://github.com/somatonic/PWOnlineInstaller/blob/master/grabpw.php)

hm... thinking about point 3 i'm not sure if that makes sens, but i'll leave it here for discussion. maybe it would be easier to do a git clone kongondos-great-pw-installer than creating an index.php, copying some lines of php that basically would do the same as my mentioned git clone?! what do you think?

i think it would be great to make the installation process as easy as possible and on the other hand more flexible than the one we already have (yes, i know we already have site profiles and whoever likes them please continue using them :D;) ). so if the installer was able to install a list of modules it could also install point 2 of my list!

i also think that this installer should be able to load standard setups of a pw-site from any url. be it a json file or some php-setup like abdus mentioned - don't know what would be better. but imagine an installer with one inputfield at the top that says:

Quote

load installation-configuration from URL: ...

this would make it possible to

  1. save your own basic pw-setups as simple gists
  2. share setups with others (eg on the forum for debugging, similar to the concept of VMs)

and all you would have to do was to put in an URL form the basic setup (that the browser should remember), choose admin username + password and database connection info. done :)

maybe a lot of what i want is already doable by adrians module toolkit? but still i think the process of installing pw in general can be optimized. or am i just missing some great options we may already have (like wireshell for example)? or can we use composer like this?

  • Like 1

Share this post


Link to post
Share on other sites
On 05/10/2017 at 7:07 AM, abdus said:

I was thinking of moving to the official multi-site solution, but I'll start with your module.

Just to clarify to those that might be confused by this line. This module is not a multi-site solution. It is a multi-site helper. You will still be using the official ProcessWire mulit-site solution. The module only helps you to auto-mate some of the manual tasks. The only notable difference is the how index.config.php is structured.

 

20 hours ago, bernhard said:

hm... what do you think of splitting it into 3 parts:

  1. some kind of advanced pw-installer
  2. a process module to handle multisite installations
  3. a single php file that grabs the pw-installer similar to the online installer from soma

I am not keen on splitting the module like this since it can, with a little tweaking, already achieve a standalone(single) installation. The only differences between a multi-site and single site are:

multi-site

  1. location of site folder -  located in same folder as the main site folder (e.g. /www/main-site/site/ for the main site and /www/main-site/site-something/ for the installed site
  2. site folder named site-something
  3. uses the existing wire folder (/www/main-site/wire/)
  4. needs index.config.php

single site

  1. location of site folder - located in its own folder (e.g. /www/another-site/site/)
  2. site folder named 'site'
  3. uses its own wire folder (/www/another-site/wire/)
  4. does not need the index.config.php

This means that all we have to do is (like you suggested earlier) tell the module in which directory on your server you want to install the single site, do the htaccess.txt renaming and copy over the wire folder as well as its index.php, LICENSE.txt, etc. That's all there is to it. The database stuff routines remain the same. So, I am thinking of a radio button to choose whether you are installing a single versus multi site, blah blah.

Edit:

In respect of selecting ProcessWire versions,  the module could check if you have a zip file in a designated folder to unzip from and if not, download the ProcessWire version of your choice, or something along those lines.

20 hours ago, bernhard said:

i also think that this installer should be able to load standard setups of a pw-site from any url. be it a json file or some php-setup like abdus mentioned - don't know what would be better. but imagine an installer with one inputfield at the top that says:

What is a standard setup :)? I am a bit jittery about the module communicating with any URL. I would prefer all that such setups are loaded locally. Maybe I am just being paranoid here :)

20 hours ago, bernhard said:

save your own basic pw-setups as simple gists

I was thinking of saving this locally. That's what I was intimating by this:

On 05/10/2017 at 6:57 AM, kongondo said:

Create installation profiles and/or allow JSON/CSV install configurations (useful for repetitive values, e.g. where Superuser email doesn’t change)

 

  • Like 4

Share this post


Link to post
Share on other sites

Update: Multi Sites Version 0.0.2.

Multi Sites can now install single/stand-alone sites! The Multi Sites in the name now means installing and managing multiple sites :P! For single sites use, the module now downloads, strips, compresses and save ProcessWire versions of your choice for reuse (rather than downloading each time you install a single site). These ProcessWire files can be refreshed on demand, e.g. when a new version of ProcessWire comes out. README is now complete. See changelog for more details.

Download from GitHub.

Changelog

  1. Support for installing single/stand-alone sites.
  2. Added Type or Paste and Install Configuration methods for creating sites.
  3. Create and edit site install configurations.
  4. Download, store and restore various versions of ProcessWire (for single-site installations).
  5. UI enhancements.

I'll update first post later.

Screens

1

multisites-version-002-001.thumb.png.68d53d6c6b893052a71068bfb71627b9.png

2

multisites-version-002-002.thumb.png.45bfc60ef15cda727665baa8a3e12bf5.png

3

multisites-version-002-003.thumb.png.094b8fe96bf13f28ec7f71f445aa7501.png

4

multisites-version-002-004.thumb.png.ead01014f6e663b87376a995b6d56ac8.png

Edited by kongondo
  • Like 6

Share this post


Link to post
Share on other sites
7 hours ago, kongondo said:

Multi Sites in the name now means installing and managing multiple sites :P!

Great news! Now I just have to find the time to try it out... BTW, how about renaming it to something like Sites Manager? Is it too late to rename it to something more descriptive and less confusing? There is another group of modules with almost the same name:

also:

Multiple solutions with multiple multies in their names are a bit confusing ;) 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, szabesz said:

BTW, how about renaming it to something like Sites Manager? Is it too late to rename it to something more descriptive and less confusing? There is another group of modules with almost the same name:

Not, it's not late at all. In fact, I forgot to mention it. I was looking for name suggestions! (one of the reasons I still left it in Alpha, actually). Thanks! I like sites manager. Let's see if there are more suggestions.

All,

Module Name

Name suggestions for this module please? We currently have:

  1. Sites Manager

Upgrading

Please note, version 002 includes some templates not in version 001. A re-installation is required I am afraid.

  • Like 1

Share this post


Link to post
Share on other sites

Can't wait to use this for something... Now all I need is a nice big client that needs multiple sites. ;-)

59 minutes ago, swampmusic said:

I am buried deep in vuejs these last weeks

In this boat as well. Vue is awesome! Somewhat of a paradigm shift, but fine - just the reactivity system on its own is great!

Share this post


Link to post
Share on other sites

Update: Multi Sites Sites Manager Version 0.0.3.

Multi Sites is dead! :o Long live Multi Sites!! :)

Happy to announce Beta Release of Sites Manager.

Please note, no upgrade path from versions 001 or 002 of Multi Sites. I have updated the first post.

Download: GitHub

Demo: Remote server single site install (PW 3.x + AdminThemeUIKit).  YouTube

Documentation: GitHub

Changelog

  1. Changed name to Sites Manager (formerly Multi Sites). Thanks to @szabesz for suggestion.
  2. Fixed bugs in Type or Paste method (key=value pairs must now be separated by new line).
  3. Beta release.
Edited by kongondo
minor cleanup
  • Like 3

Share this post


Link to post
Share on other sites

trying this out for the first time. I get this error every time i try to add my first site. Am i doing something wrong?

 

"Error saving admin account"

Screen Shot 2018-09-15 at 7.24.40 PM.png

Share this post


Link to post
Share on other sites

Hi @DxJR,

Welcome to the forums and ProcessWire. Thanks for testing the module. What ProcessWire version are you using? A recent ProcessWire update seems to have broken the module. I noticed this when setting up some sites last week. I've not had a chance to debug it yet. I am quite busy at the moment and don't know when I'll look into it. Until then, please do not to use the module in production sites. I'll update the first post.

Share this post


Link to post
Share on other sites

@kongondo thanks so much for your quick response. Newish to the forums, but been a processwire devoted user for YEARS! Excited to see what this module can do.

  • Like 2

Share this post


Link to post
Share on other sites

@kongondo hey, i know you're busy and probably haven't had time, just wanted to know if you found a solution to this yet. Thanks so much

Share this post


Link to post
Share on other sites

@DxJR Sorry, I haven't had a chance to look at it yet. If you are able to help debug it please, that would help get us there.

  • Thanks 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip
    • By psy
      Background
      I'm creating a module to integrate https://pushalert.co/ into ProcessWire. You actually don't even need a module. You could just use the "Other Websites" javascript provided by PushAlert for basic functionality, ie send a broadcast notification to all subscribers. This is essentially what all the other integrations, including WordPress, do. The WP integration installs a widget with a form enabling the admin to enter details such as title, message, etc from a blog post. It does not:
      collect any statistics within the CMS about the notification enable audience fine tuning to eg a particular subscriber or subscriber segment within WP. The admin needs to use the PA dashboard for that functionality PushAlert has a javascript and REST API. It's intended that this module will use both. https://pushalert.co/documentation 
      What my module does so far:
      associate a subscription with a user. FE user clicks a button on the website front end to subscribe and/or agrees to the browser popup to accept notifications from this site send broadcast push alerts from a page within admin It doesn't have a 'widget' but easy enough to create a fieldsetpage with the relevant fields and add that fs page to any appropriate templates, then with a hook, send the notification. Need to be careful that once published/sent, the notification is not automatically re-sent on subsequent page edits.
      Looking for help/collaboration on how best:
      to send a notification, eg from a blog post, then track the statistics. Dilemma is that the push notification must come from the admin page. Responses go to the sending page which, as it's an admin page, is restricted and will not accept the https response. This is where the other CMS integrations stop. The only json response from PushAlert is the status, eg 'success', and the notification id. There is no opportunity at this point to capture the sending page id. handle, 'once sent on page publish', do not automatically resend on future page edits Am thinking along the lines that FS Page will have a @kongondo runtime markup field https://modules.processwire.com/modules/fieldtype-runtime-markup/ to pull the stats from PushAlert. Every time an admin visits the page, the stats will update.
      Once an admin checks the 'Send notification on page publish' checkbox, a hook creates new front end page that records the 'sender page', sends the notification request to PA, which then uses that newly created frontend page, as the response endpoint. Another rook re-associates the front end page with the admin page (eg blog post), to update the stats.
      Potential use cases:
      Notify individual and/or users with a particular role of an event, eg "New work opportunity" for job seekers; new blog post published; entries now open, etc...
      Looking for help/ideas/collaboration on this module. Please let me know if you're interested and as I do, believe this would be a great addition to ProcessWire