AltME: Web

Messages

Arnold
figured out the line write %mijndoc.htmlÊgen-doc read %mijndoc.txt
makedoc2 results on the other hand were nicer but that was not it either.

Chris
The structure of MD since v2 is a separation of scanner and emitter. 'scan-doc will break text into a block of [style content] pairs. 'gen-doc will take that block and turn it into something, most commonly HTML.
The features of your doc - using your ==+, ==#, etc. are in the spec of the parser. Loosely explained, the parser's rule 'resets' when it encounters a newline.  It defines a few paragraph types that copies chunks of text (including 'paragraph that consumes text AND single newlines).  The rest of the rule determines the paragraph style and expected paragraph type:
  "===" text-line (emit sect1 text)
Could just as easily be:
  "==+" paragraph (emit my-bold-paragraph para)
The way a document is presented is all in the emitter. Seems this is where you seem to be yearning for most control. My first motivation using MakeDoc was stripping it of any styles - I just wanted a minimum of HTML markup that could be embedded and properly moulded by CSS. In my script above, I iterate through the [style content] list and use 'switch to determine how to handle each, this should be sufficient for documents without any complexity. It's really then just a case of modifying the HTML that is emitted.
Example of script used in RSP (exposes [escape-html scan-doc gen-doc]):
  <link rel="stylesheet" href="http://ross-gill.com/styles/anywhere.css">
  <% do http://reb4.me/r/xhtml %>
  <pre><code><%= mold doc: scan-doc some-input-text %></code></pre>
  <%= gen-doc doc %>
How it looks depends on the stylesheet you use.
Chris
I really should update that script though - a succinct version of make-doc though it is, it could use a bit of a refresh.

Endo
Chris: I'm trying to use oauth with Salesforce, can you help me about it?
I have consumer-key and consumer-secret, but where do I set login_url?
I'm trying your Etsy with Salesforce. I thought that I at least should be able to login.
Endo
I get "** User Error: Handshake Response does not contain Login URL" when I try etsy/as "username"

Chris
http://www.salesforce.com/us/developer/docs/api_rest/Content/quickstart_oauth.htm
Is this the API you're trying to access?  Looks as if it uses OAuth 2.0 (Etsy and Twitter are 1.0) - I'm not fully aware what the differences are.  Note that even though Twitter and Etsy both use the same signing method (OAuth), they differ in how you get the user key - looks as if this one is different again...
Hmm, that came across as unreadable here : ) - here it is again:
http://www.salesforce.com/us/developer/docs/api_rest/Content/quickstart_oauth.htm
Is this the API you're trying to access?  Looks as if it uses OAuth 2.0 (Etsy and Twitter are 1.0) - I'm not fully aware what the differences are.  Note that even though Twitter and Etsy both use the same signing method (OAuth), they differ in how you get the user key - looks as if this one is different again...
Kaj
They're quite different
Chris
Ok, in an effort to disentangle some of the OAuth code from specific implementations, here is an *experimental*, *largely untested* port scheme that does just that.
test-site: http://192.168.0.60.xip.io:8080/
probe-lowercase: func [str [string!]][
    lowercase copy str
]
read [
    scheme: 'oauth
    target: 'get
    url: test-site
    user-data: context [a: "Foo"] ; params
    key: make key [
        consumer-key: consumer-secret: "Your Keys Here"
    ]
    user: make user [token: secret: "Your User Keys Here"]
    awake: :probe-lowercase ; result processor, like :load-json
]
(obviously you'll need to change the test-site to your own test service)
I'm pretty sure this is a grevious abuse of R2's port system, but it does mean there is no new global words.
Chris
Yey! Works with Twitter!!
tm: read [
    scheme: 'oauth
    url: https://api.twitter.com/1/statuses/home_timeline.json
    target: 'get
    user-data: context [count: 10]
    key: make key [
        Consumer-Key: #consumer_key
        Consumer-Secret: #consumer_secret
    ]
    user: make user [
        token: #user_key
        secret: #user_secret
    ]
    awake: :load-json
]
Endo, I don't think this will help you with Salesforce, but breaking the OAuth part out should make it easier to adapt to OAuth 2.0.
Endo
Wow thanks a lot Chris! Thanks for separating OAuth port scheme, unfortunately I'm not familiar with OAuth but I'll try it with Salesforce. Thanks a lot!
Gabriele
Endo
I know, I already read it. But SF uses OAuth 2. :(
Endo
Is GET supported in read/custom ?
print read/custom http://localhost/test.rsp [get "a=b&c=d"]
Or should I use Graham's custom http?

Last message posted 43 weeks ago.