Coder Social home page Coder Social logo

node-ssi's People

Contributors

georgetaveras1231 avatar jbouzekri avatar jpstevens avatar nfriedly avatar yanni4night avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-ssi's Issues

Single line incrrect

if file contains ''
includeFileReg exec two expression as one
For fix need change
var includeFileReg = /<!--#\s*include\s+(file|virtual)=(['"])([^\r\n\s]+?)\2\s*(.*)-->/;

to

var includeFileReg = /<!--#\s*include\s+(file|virtual)=(['"])([^\r\n\s]+?)\2\s*(.*?)-->/;

npm WARN enoent ENOENT: no such file or directory, open '/home/mynodeproject/www/package.json'

Node v6.4.0 - Express v4.13.4 - CentOS 6.8

Hello,

When I try to install node-ssi through npm install node-ssi I get the following error. Should I make some kind of json file with settings first? If yes, how ?

/home/mynodeproject/www/package.json
└── [email protected]

npm WARN enoent ENOENT: no such file or directory, open  /home/mynodeproject/www/package.json
WARN 001 No description
npm WARN 001 No repository field.
npm WARN 001 No README data
npm WARN 001 No license field.

Feature request: Continue SSI processing if failure to resolve an include occurs with ssi.compile and ssi.compileFile

Example: An HTML file has the following three includes:

<!--#include virtual="/includes/header.html" -->
<!--#include virtual="/includes/content.html" -->
<!--#include virtual="/includes/footer.html" -->

In my situation, the first and last include do not exist on my local development environment, however they will be available once pushed to the test / prod. environment. I am only concerned about rendering the second include, content.html.

The problem is that since the first include does not exist, ssi.compileFile (and ssi.compile) throws an error which means the downstream includes are not processed. In my case, I am using ssi.compile().

return ssi.compile(text, function (err, content) { 
});

As a workaround, I was thinking I could grab the failed reference from err, and parse the original input file content to remove the offending reference then pass this back in to ssi.compile / ssi.compileFile until it has fully processed.

Would like to get your thoughts on implementing continuation of processing on error, however.

Support for multiple directories

Not sure if this is a new or existing issue but I am currently trying to migrate from nginx server with support for ssi to a bespoke node/express server.

The current setup has files in different locations. So for example

we might have root set to

../file_path/www-root

ssi components aliased in say:

../another_file_path/components

and say ssi modules in say ../yet_another_path/modules/

I also have say library and theme folders that serve different files depending on the host url.

Therefore I can have brand1.dev/ brand2.dev etc which is referenced in .htaccess, and I can again use node to route the files accordingly. These are generally not .shtml files but again there may be a some .shtml referenced in these locations

So my question is it possible to use node-ssi to support these multiple locations?

p.s. was kind of getting this confused with this repo.:

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

Create a basic example app for README?

If I'm understanding correctly, the example given in the current README doesn't actually show how to quickly run a server with this.

Can you post simple example code that can be used to simply server pages in a folder?

For example, I'd like to be able to run node index.js from a directory containing an index.html file and for that to immediately start a server on localhost:8080 serving that file (and any other linked images, sub-links, SSI includes, etc.) automatically (for developing locally without having to install nginx on a dev machine).

是否支持#config

'''
《!--#config timefmt="%Y%m%d%H%M%S" --》

var SERVER_TIME_STR = '';
'''

我这样写的,,大多数ssi都不知道config...你这个是否可以

Cool project!

👍 Just wanted to let you know that I'm excited to see this, and I'm going to try it out because we have a use for it: okTurtles/okturtles.com#15

Thanks! Hope it works! crosses-fingers

Using `=` with a variable in an `#if` statement causes the variable's value to change

When Apache parses SSI statements, it treats = and == as equivalent in conditional expressions, and if a variable is on the left side of the operator, the variable's value remains unchanged after the statement is evaluated.

For example, if variableName is set to 'someValue', then <!--#if expr="$variableName = 'anotherValue'"--> and <!--#if expr="$variableName == 'anotherValue''"--> will both evaluate as false, and variableName's value will still be someValue.

In node-ssi, however, using = with a variable in an #if statement causes the variable's value to change. The workaround is to use == instead, but ideally that shouldn't be necessary.

Test Code

I created a test here: https://runkit.com/lordpachelbel/runkit-npm-node-ssi — You can click the tiny arrow to the left of the console output to see it rendered as HTML.

The unminified version of the HTML string in that test is this:

<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8" />

<title>SSI test page</title>

</head>


<body>

<h1>SSI test page</h1>

<p>Initial <code>#set</code> happens here.</p>
<!--#set var="loginStatus" value="on"-->

<p><code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>

<h2>Using <code>==</code></h2>

<p><code>#if expr="$loginStatus == 1"</code> :<br />
<!--#if expr="$loginStatus == 1"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus == '1'"</code> :<br />
<!--#if expr="$loginStatus == '1'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus == 'on'"</code> :<br />
<!--#if expr="$loginStatus == 'on'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus == ''"</code> :<br />
<!--#if expr="$loginStatus == ''"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus == 'anything'"</code> :<br />
<!--#if expr="$loginStatus == 'anything'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<h2>Using <code>=</code></h2>


<p><code>#if expr="$loginStatus = 1"</code> :<br />
<!--#if expr="$loginStatus = 1"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus = '1'"</code> :<br />
<!--#if expr="$loginStatus = '1'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus = 'on'"</code> :<br />
<!--#if expr="$loginStatus = 'on'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus = ''"</code> :<br />
<!--#if expr="$loginStatus = ''"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


<p><code>#if expr="$loginStatus = 'anything'"</code> :<br />
<!--#if expr="$loginStatus = 'anything'"-->
  <span style="color: white; background: green;">enabled</span>
<!--#else-->
  <span style="color: white; background: red;">disabled</span>
<!--#endif-->
<br />
<code>loginStatus</code>: <code><!--#echo var="loginStatus"--></code></p>


</body>
</html>

Screenshots

As rendered by Apache

screen shot 2018-02-21 at 13 09 44

As rendered by Node and node-ssi

screen shot 2018-02-21 at 13 09 54

The top and bottom parts of the test page are supposed to look the same, but the variable's value is changed by the last four #if statements. Note that the only time the = works as intended is the first one in the bottom section, and I assume it has something to do with the fact that that conditional is doing a numerical comparison instead of a string comparison.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.