kidwm / grunt-ssi

Grunt Plugin to compile HTML with SSI into static HTML pages
MIT License
9 stars 9 forks source link

use node-ssi #20

Open kidwm opened 8 years ago

kidwm commented 8 years ago

Hi, I'm the new maintainer of node-ssi.

https://github.com/kidwm/node-ssi

I can take over this project and make this grunt plugin based on node-ssi.

my npm id is also kidwm, how do you think, would you like to transfer it to me?

anguspiv commented 8 years ago

Yeah, I have no problem with that. I will say I originally tried to use node-ssi, but wanted to also create a caching system, similar to sass. So I found it difficult to integrate with node-ssi. But this is all yours now. I will note that you might want to upgrade the version of grunt it relies on. Let me know if you have any questions.

kidwm commented 8 years ago

@anguspiv Thank you, if you were still interested to create a caching system in node-ssi, welcome to contribute!

taoeffect commented 8 years ago

There's also @yanni4night's node-ssi which I use and can vouch for. What's the difference between these two node-ssi projects?

taoeffect commented 8 years ago

Oh, one difference that I've found is that ssi's API requires the creation of files whereas @yanni4night's node-ssi does not. That's very convenient for creating middleware using grunt-contrib-connect (something that I'm working on right now).

taoeffect commented 8 years ago

Yep! :smile:

grunt-contrib-connect works great with @yanni4night's node-ssi, no need for any temporary cache files or new grunt plugins, just do:

    connect: { // https://github.com/gruntjs/grunt-contrib-connect
      options: {
        port: 8000,
        base: 'dist',
        livereload: true,
        middleware: (connect, opts, middlewares) => {
          middlewares.unshift((req, res, next) => {
            var f = url.parse(req.url).pathname
            f = path.join('dist', S(f).endsWith('/') ? f + 'index.html' : f)
            if (S(f).endsWith('.html') && fs.existsSync(f)) {
              ssi.compileFile(f, (err, content) => {
                if (err) {
                  console.error(err.stack)
                  throw err
                }
                console.log(`Req: ${req.url} => sending node-ssi parsed file: ${f}`)
                res.end(content)
              })
            } else {
              next()
            }
          })
          return middlewares
        }
      },
      dev: {}
    }
thany commented 8 years ago

Did this endeavor come through yet? I would very much like the functionality of node-ssi in a grunt task, but I'm not sure that it's possible without it being an actual grunt task module.

kidwm commented 8 years ago

@thany Not yet, thanks for your appreciation. I'm still busy with my new daily job. Hope to find some time for it soon.