REBOL [
Title: "Make recipe web page"
Purpose: {Assemble all recipes in the current folder into
a single web page and send it to an ftp site.}
]
;; [---------------------------------------------------------------------------]
;; [ The program reads all the recipes in the current directory and makes ]
;; [ a single web page of all of them, and then sends it to a hard-coded ]
;; [ ftp site. Many ISP's give a customer a small amount of space for a ]
;; [ personal web site, and this program was designed around that premise. ]
;; [ The reason one would want one's recipes on a personal web site might ]
;; [ be to cover the situation where one is at the grocery store and decides ]
;; [ at the last minute to make a particular recipe for dinner, and can't ]
;; [ remember the ingredients. With the recipes on a web site, a person ]
;; [ could check the list on a smart phone. ]
;; [---------------------------------------------------------------------------]
;; [---------------------------------------------------------------------------]
;; [ Change the items below for your personal situation. ]
;; [---------------------------------------------------------------------------]
WEBSITE-ADDR: "ftp.myisp.com"
WEBSITE-USERID: "myemailid@myisp.com"
WEBSITE-PASSWORD: "mypassword"
OUTPUT-FILE-ID: %recipe-list.html
;; [---------------------------------------------------------------------------]
;; [ These are the data structures that seem to be required to send the ]
;; [ files we want to send. The tenth item in each block is the file ]
;; [ name on the server. ]
;; [---------------------------------------------------------------------------]
TOPIC-ADDR: [
scheme: 'ftp
host: WEBSITE-ADDR
user: WEBSITE-USERID
pass: WEBSITE-PASSWORD
target: %.
]
TOPIC-ADDR/10: OUTPUT-FILE-ID
;; -- Get a list of all text files in the current directory.
TEXT-FILE?: func [
FILEID
] [
find [%.txt %.TXT] find/last FILEID "."
]
FILE-LIST: read %.
while [not tail? FILE-LIST] [
either TEXT-FILE? first FILE-LIST [
FILE-LIST: next FILE-LIST
] [
remove FILE-LIST
]
]
FILE-LIST: head FILE-LIST ;; Don't forget to reposition to head.
HTML-PAGE: ""
HTML-INDEX: ""
HTML-INDEX-LINE: {
<% RECIPE-NAME %>
}
HTML-HEAD: {
<% RECIPE-NAME %> |
<% WS-INGREDIENT-LIST %> |
<% RECIPE-PROCEDURE %> |
<% RECIPE-NOTES %> |