question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple instances on the Same Site

See original GitHub issue

Enhancement

Currently there is support for only one instance of Staticman per static site since the staticman property is a hash in the configuration file. For instance _config.yml:

staticman:
  name          : "comments"
  allowedFields : ['name', 'email', 'url', 'message']
  branch        : "master"
  commitMessage : "New comment."
  filename      : comment-{@timestamp}
  format        : "yml"
  moderation    : true
  path          : "_data/comments/{options.slug}"
  requiredFields: ['name', 'email', 'message']
  transforms:
    email       : "md5"

I am wondering if more than one configuration could be specified if the staticman property could be an array. Each hash in the array, requires an additional property name, and in the submitted form, we must pass an additional required field options[name] with the corresponding name value so that the server can know which instance to use. This would be backward compatibility, since if the staticman property is a hash, it behaves like it does in the current version, and if it is an array, it enables this new behaviour. For example:

staticman:

  - name          : "ideas"
    allowedFields : ['title', 'description']
    branch        : "master"
    commitMessage : "New idea."
    filename      : idea-{@timestamp}
    format        : "yml"
    moderation    : true
    path          : "_data/ideas/{options.slug}"
    requiredFields: ['title', 'description']

  - name          : "comments"
    allowedFields : ['name', 'email', 'url', 'message']
    branch        : "master"
    commitMessage : "New comment."
    filename      : comment-{@timestamp}
    format        : "yml"
    moderation    : true
    path          : "_data/comments/{options.slug}"
    requiredFields: ['name', 'email', 'message']
    transforms:
      email       : "md5"
<form method="POST" action="https://api.staticman.net/v1/entry/my/repo/master">
  <input name="options[name]" type="hidden" value="ideas">
  <input name="options[slug]" type="hidden" value="{{ page.slug }}">
  <label><input name="fields[title]" type="text">Title</label>
  <label><textarea name="fields[description]"></textarea>Description</label>
  <button type="submit">Submit Idea!</button>
</form>

<form method="POST" action="https://api.staticman.net/v1/entry/my/repo/master">
  <input name="options[name]" type="hidden" value="comments">
  <input name="options[slug]" type="hidden" value="{{ page.slug }}">
  <label><input name="fields[name]" type="text">Name</label>
  <label><input name="fields[email]" type="email">E-mail</label>
  <label><textarea name="fields[message]"></textarea>Message</label>
  <button type="submit">Submit Comment!</button>
</form>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eduardoboucascommented, Sep 29, 2016

Also, I’m thinking the name of the instance should be provided as part of the URL instead of relying on a form field, being such a crucial setting.

So something like:

https://api.staticman.net/v2/entry/{your GitHub repository}/{your repository name}/{the name of the branch}/{the name of the instance}

With the name of the instance being optional.

1reaction
eduardoboucascommented, Sep 29, 2016

I like this!

I think I would prefer to add this for version 2 of the endpoint (see #5 for more details). Sharing the configuration file with Jekyll was a design mistake, and “polluting” it to yet more Staticman-related stuff doesn’t seem ideal.

With version 2, we have a dedicated configuration file for Staticman, and in that case yes, absolutely. Maybe each instance could be a property within the main object and get rid of name, so something like:

ideas:
  - allowedFields : ['title', 'description']
    branch        : "master"
    commitMessage : "New idea."
    filename      : idea-{@timestamp}
    format        : "yml"
    moderation    : true
    path          : "_data/ideas/{options.slug}"
    requiredFields: ['title', 'description']

comments:
  - allowedFields : ['name', 'email', 'url', 'message']
    branch        : "master"
    commitMessage : "New comment."
    filename      : comment-{@timestamp}
    format        : "yml"
    moderation    : true
    path          : "_data/comments/{options.slug}"
    requiredFields: ['name', 'email', 'message']
    transforms:
      email       : "md5"

Does that sound reasonable?

Thanks for creating the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple instances of a web site on a single server - upgrade ...
The issue is when I need to update the site (its code not the infrastructure). I think I could minimize downtime by taking...
Read more >
One Website to be connected with Multiple EC2 Instance?
Since the data is not local to the instance anymore, you can easily have multiple instances all using the same storage.
Read more >
What are the benefits of multiple instances? - Atlassian Support
An instance is a self-contained copy of a specific product. If you have a single instance of a product, everyone works together in...
Read more >
Same site multiple instances with one DB - nopCommerce
Dears, We have a site developed using NopCommerce, we copied exactly same site on 3 different servers for load balancer.
Read more >
Multiple instances of same page with different dynamic data
Open another instance of the same page, select another decoder and one can easily switch between the two. I hope that that makes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found