Search code examples
seaside

What's an easy way to dynamically generate some JavaScript in Seaside?


I'm trying to add Disqus to a blog I'm writing. To deal with Seaside sessions I need to either add a unique discus_identifier or disqus_url to the JS. I overrode my component's #script method but it can only return a string literal.

I see two options:

  1. Dynamically generate the JS, save it to a file, and load that file in to my component.
  2. Add a permalink for each blog entry.

Is there an easier way? Or is one (or both) of these ways easy to do? I'm new to Smalltalk and Seaside and am unsure how to accomplish either of these two things.


Solution

  • Yes there is an easier way. You can generate the correct Discus JS code directly in the #script method. It should return a String literal but you can create this String on the fly. For example by using a WriteStream.

    You blog entries also need a permalink. You can use the #initialRequest: method to handle these permalinks.