# How offer a list of PDF files?

**URL:** <https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408>\
**Category:** Radiant CMS\
**Created:** [October 5, 2007, 7:57am UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408 "2007-10-05T07:57:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 7:57am UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/1 "2007-10-05T07:57:30Z")

</div>

I want to expose an archive of PDFs of monthly newsletters.  
I don’t want to create a “Page” entity for each file.  
I’d instead like some way to iterate through the file system via some  
glob, something like

\<r:findfile glob=“newsletters/\*.pdf”\>  
\<r:url/\>  
\</r:findfile\>

Where a relative path in the glob is relative to “public”.

Actually, what I really want is also the ability to extract information  
from the filenames, which are typically like “newsletter-2007-04.pdf”.  
So then it might hypothetically be:

\<r:findfile glob=“newsletters/\*.pdf”\>  
\<r:matches string="\<r:url/\>" expr="/newsletter-(\d+)-(\d+)/"/\>  
\<r:match value="$1"/\> \<r:month-name  
month="$2"/\>  
\</r:findfile\>

The above is rather ugly, but anyhow, I can’t seem to find any way to do  
the above.

I’m debating whether I shouldn’t write a perl program to generate an RSS  
file  
based on the existing pdfs, put that in a cron job, and then have  
Radiant process  
that external RSS file using the “externalrss” extension.  
Except I can’t figure out yet how to get any extensions installed…

-mda

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 8:03am UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/2 "2007-10-05T08:03:21Z")

</div>

Mark D. Anderson wrote:

> I’m debating whether I shouldn’t write a perl program to generate an RSS file  
> based on the existing pdfs, put that in a cron job, and then have Radiant process  
> that external RSS file using the “externalrss” extension.  
> Except I can’t figure out yet how to get any extensions installed…
> 
> -mda

My thought process would be to dump them in a sub-directory of public  
and then add an extension/ tag that lets you iterate through it. I’m  
not sure if you could just use the page\_attachments extension, though?

Cheers,  
Mohit.  
10/5/2007 | 2:01 PM.

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 10:38am UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/3 "2007-10-05T10:38:25Z")

</div>

With the backdoor extension ([http://backdoor.rubyforge.org/](http://backdoor.rubyforge.org/)) you can do  
something in the line of:

\<r:erb\>  
\<% Dir.glob( “newsletters/\*.pdf”) do |file|  
if file =~ /…/  
%\>  
\<a href="\<%= file%\> …   
\<% end %\>  
\</r:erb\>

```
/AITOR

```

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/4 "2007-10-05T14:54:26Z")

</div>

Have you looked at PageAttachments? It gives you the ability to  
upload files through the page editor interface and then reference each  
one using Radius tags.

[http://wiki.radiantcms.org/Installing\_Extension\_-\_Page\_Attachments](http://wiki.radiantcms.org/Installing_Extension_-_Page_Attachments)  
[http://svn.seancribbs.com/svn/rails/plugins/extensions/page\_attachments/](http://svn.seancribbs.com/svn/rails/plugins/extensions/page_attachments/)

-Andrew

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 5:18pm UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/5 "2007-10-05T17:18:18Z")

</div>

you can also use the gallery extension creating a gallery called  
Newsletter  
and some subgallery for each month…in each subgallery you can upload  
you pdf’s.

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/6 "2007-10-05T17:25:55Z")

</div>

I’m also doing something similar with PageAttachments. I highly  
recommend it.

- Ryan

On Oct 5, 2007, at 7:53 AM, Andrew O’Brien wrote:

> On 10/5/07, Aitor Garay-Romero [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > \</r:erb\>
> > 
> > > So then it might hypothetically be:
> > > 
> > > -mda  
> > > Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)
> 
> * * *
> 
> Radiant mailing list  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

* * *

Ryan H.  
Art of Mission, Inc.  
3720 Gattis School Rd #800 PMB 245  
Round Rock, TX 78664

800-722-1492

[www.artofmission.com](http://www.artofmission.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Mark\_DSAnderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Mark\_DSAnderson](https://www.ruby-forum.com/u/Mark_DSAnderson)\
**Post date:** [October 5, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/how-offer-a-list-of-pdf-files/116408/7 "2007-10-05T23:28:50Z")

</div>

On Fri, 5 Oct 2007 10:37:15 +0200, “Aitor Garay-Romero” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
said:

> \</r:erb\>  
> Thanks, I got this to work. For the record, here is what I ended up with  
> (you were missing a second closing “end”):

## Archive:
 \<% year = 0 Dir.glob( "healthyconnpdfs/\*.pdf").sort().reverse().each do |file| if file =~ /healthyconnex-(\d+)-(\d+)-(\w+)\.pdf/ %\> \<%= year == $1 ? '' : "
### #{$1}
" %\> \<%= Time.gm($1, $2).strftime("%B")%\> (\<%=$3%\>)  
 \<% year = $1 %\> \<% end end %\>

-mda
