Re: [pollen] getting the filename of current input source in pollen.rkt

2019-03-28 Thread Ifeoluwapo Eleyinafe
Great advice. Thanks so much. So I've defined an arbitrary function:
(define (output-filename meta-source)
   (path->string
(car (reverse (explode-path (string->path (select-from-metas 'here-path 
meta-source)))

Then I call it from within a tag function like so:
(output-filename (current-metas))

Just want to say thanks again. In hindsight, here are the words from the 
manual about (current-metas):
"Holds the metas of the current Pollen source. In tag functions, ..."

Have a good evening and I really appreciate your help and that of Mr. 
Butterick.

On Thursday, March 28, 2019 at 10:10:02 PM UTC-4, Sorawee Porncharoenwase 
wrote:
>
> Can we see your pollen.rkt? Anyhow, it’s very likely that you call 
> (current-metas) outside of tag functions. 
>
> (current-metas) is “undefined” outside of tag functions, which make sense 
> if you think about it: pollen.rkt can be used by several Pollen markup 
> files, and each markup file can define different metas. Therefore, outside 
> of tag functions, the concept of metas is not well-defined.
>
> On the other hand, a tag function is invoked from markup files, so it's 
> possible to associate metas to (current-metas).
> corr
>
> On Thu, Mar 28, 2019 at 5:12 PM Ifeoluwapo Eleyinafe  > wrote:
>
>> Thanks so much for the quick reply. So I tried to access (current-metas) 
>> from the pollen.rkt but I keep getting false.
>> I tried creating a test meta with (define-meta ...) but it was not 
>> accessible and it wasn't visible on (current-metas).
>> Tried running (select-from-metas) from pollen.rkt but metas was an 
>> unbound identifier.
>> I'm sure I'm doing something wrong. I'll keep re-reading the 
>> documentation.
>>
>> Thanks much for your help.
>>
>> On Thursday, March 28, 2019 at 11:21:27 AM UTC-4, Matthew Butterick wrote:
>>>
>>>
>>> On Mar 28, 2019, at 6:23 AM, Ifeoluwapo Eleyinafe  
>>> wrote:
>>>
>>>
>>>  I think I can pull from metas using 'here-path but I don't know how to 
>>> access metas from pollen.rkt. I can do so from the template file but then I 
>>> won't be able to use the data in my tag definitions.
>>>
>>>
>>> Import `pollen/core` and use `current-metas`:
>>>
>>>
>>> https://docs.racket-lang.org/pollen/Core.html?q=current-metas#%28def._%28%28lib._pollen%2Fcore..rkt%29._current-metas%29%29
>>>  
>>> 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Pollen" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to poll...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] getting the filename of current input source in pollen.rkt

2019-03-28 Thread Sorawee Porncharoenwase
Can we see your pollen.rkt? Anyhow, it’s very likely that you call
(current-metas) outside of tag functions.

(current-metas) is “undefined” outside of tag functions, which make sense
if you think about it: pollen.rkt can be used by several Pollen markup
files, and each markup file can define different metas. Therefore, outside
of tag functions, the concept of metas is not well-defined.

On the other hand, a tag function is invoked from markup files, so it's
possible to associate metas to (current-metas).
corr

On Thu, Mar 28, 2019 at 5:12 PM Ifeoluwapo Eleyinafe 
wrote:

> Thanks so much for the quick reply. So I tried to access (current-metas)
> from the pollen.rkt but I keep getting false.
> I tried creating a test meta with (define-meta ...) but it was not
> accessible and it wasn't visible on (current-metas).
> Tried running (select-from-metas) from pollen.rkt but metas was an unbound
> identifier.
> I'm sure I'm doing something wrong. I'll keep re-reading the documentation.
>
> Thanks much for your help.
>
> On Thursday, March 28, 2019 at 11:21:27 AM UTC-4, Matthew Butterick wrote:
>>
>>
>> On Mar 28, 2019, at 6:23 AM, Ifeoluwapo Eleyinafe 
>> wrote:
>>
>>
>>  I think I can pull from metas using 'here-path but I don't know how to
>> access metas from pollen.rkt. I can do so from the template file but then I
>> won't be able to use the data in my tag definitions.
>>
>>
>> Import `pollen/core` and use `current-metas`:
>>
>>
>> https://docs.racket-lang.org/pollen/Core.html?q=current-metas#%28def._%28%28lib._pollen%2Fcore..rkt%29._current-metas%29%29
>> 
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Pollen" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pollenpub+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] getting the filename of current input source in pollen.rkt

2019-03-28 Thread Ifeoluwapo Eleyinafe
Thanks so much for the quick reply. So I tried to access (current-metas) 
from the pollen.rkt but I keep getting false.
I tried creating a test meta with (define-meta ...) but it was not 
accessible and it wasn't visible on (current-metas).
Tried running (select-from-metas) from pollen.rkt but metas was an unbound 
identifier.
I'm sure I'm doing something wrong. I'll keep re-reading the documentation.

Thanks much for your help.

On Thursday, March 28, 2019 at 11:21:27 AM UTC-4, Matthew Butterick wrote:
>
>
> On Mar 28, 2019, at 6:23 AM, Ifeoluwapo Eleyinafe  > wrote:
>
>
>  I think I can pull from metas using 'here-path but I don't know how to 
> access metas from pollen.rkt. I can do so from the template file but then I 
> won't be able to use the data in my tag definitions.
>
>
> Import `pollen/core` and use `current-metas`:
>
>
> https://docs.racket-lang.org/pollen/Core.html?q=current-metas#%28def._%28%28lib._pollen%2Fcore..rkt%29._current-metas%29%29
>  
> 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] getting the filename of current input source in pollen.rkt

2019-03-28 Thread Matthew Butterick

> On Mar 28, 2019, at 6:23 AM, Ifeoluwapo Eleyinafe  > wrote:

>  I think I can pull from metas using 'here-path but I don't know how to 
> access metas from pollen.rkt. I can do so from the template file but then I 
> won't be able to use the data in my tag definitions.

Import `pollen/core` and use `current-metas`:

https://docs.racket-lang.org/pollen/Core.html?q=current-metas#%28def._%28%28lib._pollen%2Fcore..rkt%29._current-metas%29%29
 


-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Enthusiastic thank you and beginner question about metas

2019-03-28 Thread Matthew Butterick


> On Mar 28, 2019, at 12:42 AM, Zach Mandeville  
> wrote:
> 
> And below this I wanted a function to turn ◊author into that details element 
> by referencing ◊author text against that 'scuttlebutts' meta...but, I can't  
> get it to work.  The closest I got is this:

FWIW though you call `scuttlebutts` a "meta", in terms of Pollen terminology, 
that's imprecise. "Metas" are key/value pairs stored by a Pollen source 
(usually with `define-meta`), and exported via the `metas` hash table. 

The `select-from-metas` function is just a disguised version of `hash-ref`. So 
it won't complain about your attempt to treat `scuttlebutts` as a source of 
quasi-metas, because it's also a hash.

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Enthusiastic thank you and beginner question about metas

2019-03-28 Thread Sorawee Porncharoenwase
You might want to try this pollen.rkt

#lang racket

(provide (all-defined-out))

(define scuttlebutts
  (hash
   "Gillis" "@a;lksjd2j3j1k2j.sha256f"
   "Brenda" "@s8/sj31l13j2k32.sha256"))

(define (author name)
  `(details (summary ,name) (p ,(hash-ref scuttlebutts name

And here’s the output:

'(root
  (title "A Cool Essay")
  "\n"
  (details (summary "Brenda") (p "@s8/sj31l13j2k32.sha256"))
  "\n"
  "\n"
  "this is the essay and all the paragraphs and all that")

Notice the following changes:

   1. I convert keys of scuttlebutts to strings so that I do not need to
   convert name in the author function to symbol.
   2. Since name will always be one string in your use case, you don’t need
   to use the rest argument.
   3. You want to compute (hash-ref scuttlebutts name), so it’s needed to
   be unquoted with ,.

To perfectly get the output that you indicate above, you also need to
define the root function that decodes paragraphs. You also need to define
the title function which creates the h1 tag.

On Thu, Mar 28, 2019 at 12:42 AM Zach Mandeville 
wrote:

> Hello!
>
> Thank you v. much for dreaming up and creating pollen (and thanks to all
> y'all making cool things with it!).  I discovered it through an article
> about medium, from practical typography, that was shared with me.  Pollen
> represents exactly what I want for a web publishing tool.  Especially the
> notion of creating your own tags, that can then be rendered however you'd
> like in html (or other forms).  That's philosophically just so good to me!
>
> The dilemma I have now, though, is that I started to write in pollen
> first, defining tags as I went along, and then found out I didn't quite get
> how to turn them into the html elements I want.  Worse, I enjoy writing in
> the pollen style so much  that I can't go back.  So I have an html.pm
> that I can't quite figure out how to turn into the .html i'm envisioning,
> and hoping someone here might be able to help?
>
> What I'd like is to have a list of essays by different authors, and each
> author has an id attached to them (it's authors from Scuttlebutt
> , and so each person has a public key ID
> associated with them).  the ID is long and strange, and so I don't wanna
> have to enter it each time.
>
> So for an essay, I'd have:
>
> ◊title{A Cool Essay}
> ◊author{Brenda}
>
>
> this is the essay and all the paragraphs and all that
>
> And I'd want this html:
>
> A Cool Essay
> 
>   Brenda
>   @s8/sj31l13j2k32.sha256
> 
> this is the essay and all the paragraphs and all that
>
> In my pollen.rkt I created a meta hash that had each author's name and
> their ID:
>
> (define scuttlebutts
>   (hash
>'Gillis "@a;lksjd2j3j1k2j.sha256f"
>'Brenda "@s8/sj31l13j2k32.sha256"))
>
> And below this I wanted a function to turn ◊author into that details
> element by referencing ◊author text against that 'scuttlebutts' meta...but,
> I can't  get it to work.  The closest I got is this:
>
> (define (author . elements)
>   `(details (summary ,@elements)(p `(select-from-metas elements
> scuttlebutts
>
>
> Essentially, I can't figure out how to have the value of the for the p
> x-expression to be the result of the select-from-metas expression.  I know
> it's likely something to do with quoting or some such, but I don't have
> enough racket knowledge (yet) to quite make sense of it.
>
> So my question is: what would be the best way to accomplish this?  Is
> there a correction to my function I'm missing, or would y'all recommend
> going about this in a wholly different way?
>
> Thank you!  And thank you again for this wonderfully strange language!
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Pollen" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pollenpub+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Enthusiastic thank you and beginner question about metas

2019-03-28 Thread Zach Mandeville
Hello!

Thank you v. much for dreaming up and creating pollen (and thanks to all 
y'all making cool things with it!).  I discovered it through an article 
about medium, from practical typography, that was shared with me.  Pollen 
represents exactly what I want for a web publishing tool.  Especially the 
notion of creating your own tags, that can then be rendered however you'd 
like in html (or other forms).  That's philosophically just so good to me!

The dilemma I have now, though, is that I started to write in pollen first, 
defining tags as I went along, and then found out I didn't quite get how to 
turn them into the html elements I want.  Worse, I enjoy writing in the 
pollen style so much  that I can't go back.  So I have an html.pm that I 
can't quite figure out how to turn into the .html i'm envisioning, and 
hoping someone here might be able to help?

What I'd like is to have a list of essays by different authors, and each 
author has an id attached to them (it's authors from Scuttlebutt 
, and so each person has a public key ID associated 
with them).  the ID is long and strange, and so I don't wanna have to enter 
it each time.

So for an essay, I'd have:

◊title{A Cool Essay}
◊author{Brenda}


this is the essay and all the paragraphs and all that

And I'd want this html:

A Cool Essay

  Brenda
  @s8/sj31l13j2k32.sha256

this is the essay and all the paragraphs and all that

In my pollen.rkt I created a meta hash that had each author's name and 
their ID:

(define scuttlebutts
  (hash
   'Gillis "@a;lksjd2j3j1k2j.sha256f"
   'Brenda "@s8/sj31l13j2k32.sha256"))

And below this I wanted a function to turn ◊author into that details 
element by referencing ◊author text against that 'scuttlebutts' meta...but, 
I can't  get it to work.  The closest I got is this:

(define (author . elements)
  `(details (summary ,@elements)(p `(select-from-metas elements scuttlebutts



Essentially, I can't figure out how to have the value of the for the p 
x-expression to be the result of the select-from-metas expression.  I know 
it's likely something to do with quoting or some such, but I don't have 
enough racket knowledge (yet) to quite make sense of it.

So my question is: what would be the best way to accomplish this?  Is there 
a correction to my function I'm missing, or would y'all recommend going 
about this in a wholly different way?

Thank you!  And thank you again for this wonderfully strange language!




-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.