Sharing partials between middlemanapp projects

Hi all,

What’s the best way to share middlemanapp components, such as partials, between different middlemanapp projects?

I have a website A (that uses middlemanapp) and a website B (that uses middleamanapp also). Since both websites belong to the same company, I would like to share common partials (e.g. footer). These components shouldn’t be public and I don’t have a private gem server installed in the company.

Thank you for your comments.

Best,
Vasco

If they are on the same disk, a symbolic link may do the trick. ln source_file target_directory (on unix/mac). This makes the same file appear on two different locations, so editing either one will change all occurrences of the file.

I’m using a common git repo that various projects inherit from.

When I start a new project, I clone the base repo. When making changes, I try to make them generic enough so I can push the changes “upstream” to the common repo and all the rest of the projects inherit the changes with a simple “git pull”.

However, I’m quite familiar with git, branches, cherry-picking, and conflict resolution* (git is quite good about figuring stuff out, but sometimes you’ll conflict with yourself simply because you want to do something small a bit different on one particular site, and keep the changes).

* Since I’m on Linux, I use “Meld” (which is also available on OS X and Windows, but there are other 3-way merge tools too). You may want to read a slightly old, but still good writeup which talks about the concept and demonstrates OS X’s developer mergetool and links to a few others.

If you have the sites version controlled (and you really should have them version controlled, BTW) and don’t want to deal with porting changes between them, you could just copy the files you care about around and check them in. But it’s really nice to be able to let the code flow between the repos and have all sites easily benefit from improvements without having to hand-copy files around.

Hi I have my partial library on GitHub


(if anyone wants to contribute that would be great) :slight_smile: Or share theres.

I simply either add this as a sub-module and then I have a thor file: which I run to setup all the symbolic links.

ie…

If the library is always kept in the same place then each proiject and each developer can run the same thor file with ease.

http://whatisthor.com/

##
# SymLinks
##
desc "links", "links"
def links
    system( "clear" )
    say( "\n\t Create Symlinks\n\t" )

    # JavaScript Library
    system( "rm -R source/assets/javascripts/_library-js" )
    system( "ln -s /var/www/library/middleman/_library-js source/assets/javascripts" )

    # SCSS Library
    system( "rm -R source/assets/stylesheets/_library-scss" )
    system( "ln -s /var/www/library/middleman/_library-scss source/assets/stylesheets/" )

Thank you very much for your answers and ideas.

Best,
Vasco