views:

264

answers:

1

I have the following directory structure in the CMS application we have written:

/application
/modules
   /cms
      /filemanager
      /block
      /pages
      /sitemap
   /youtube
   /rss
/skin
   /backend
      /default
         /css
         /js
         /images
   /frontend
     /default
         /css
         /js
         /images

Application contains code specific to the current CMS implementation, i.e code for this specific cms. Modules contain reusable portions of code that we share across projects, such as libraries to work with youtube or rss feeds. We include these as git submodules, so that we can update the module in any website and push the changes back across all other projects. It makes it really easy to apply a change to our code and distribute it. We wanted to turn the CMS into a module so we get the same benefit - we can run the entire project under source control, then update the cms as required through a git-submodule. We have run into a problem however: the cms requires javascript/images/css in order for it to work correctly.

Things we have thought about:

  • We could create 2 submodules, one for cms-skin and one for cms, but this means you cannot "git pull" one version without having some idea of which versions of skin work with which versions of cms. i.e version 1.2.2 CMS might have issues with 1.0.3 CMS-Skin

  • We could add the skin to the cms module but this has the following problems:

    1. Skin should be available on the document root, module code shouldn't be, and if it is it should probably be secured via .htaccess
    2. It doesn't seem to make any sense bundling assets with php code
    3. We could create a symlink between /skin/backend/ to go to /modules/cms/skin but does this cause any security problems, and do we want to require something like a symlink for the application to work?
    4. We could create a hook for git or a shell script that copies files from modules/cms/skin to skin/backend when an update occurs, but this means we lose the ability to edit CMS core files in a project then push them back

How is this typically done in large scale cms's? How is it possible to get the source code for a cms under version control, work on the application for a client, then update the sourcecode as releases and given by the vendor? How do applications like Magento or Drupal do this?

+1  A: 

I am not familiar with CMS projects, but could you:

  • create 2 submodules, one for cms-skin and one for cms
  • use the cms-skin as a nested submodule within cms

cms would be a "main project" for cms-skin, meaning each time you commit cms, you would have committed cms-skin first, and the "cms commit" would embark the exact SHA1 reference of the cms-skin used at the time of the commit.

That way you can pull only cms, and with it will come the exact version of cms-skin you need.

For more, see this SO answer about the true nature of submodules.

VonC
sure - I understand that git repos track the current state of the submodules via their sha-hash, the problem is though that putting the cms-skin inside the cms causes lots of other issues, which I explained above
Mike
@Mike: yes but I didn't get exactly what the limitations were. The idea would be to a/ insert skin at an appropriate place within cms, b/ insert a version of skin (i.e. a special branch) with the content reorganized to be compliant with its new location (i.e. within cms)
VonC
"Skin should be available on the document root, module code shouldn't be, and if it is it should probably be secured via .htaccess"
Mike