r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Rebol School] Rebol School

Henrik
29-May-2010
[3197]
off putting: some parts that can be off putting for me are parts 
in REBOL 2 that are not completed, such as the GUI system (for which 
several replacements exist) and some lack of tools for debugging, 
but REBOL 3 will solve most of these problems. The rest is a joy 
to use.
florin
29-May-2010
[3198]
It's so different and so 'free form'. I'm not interested in the GUI 
part right now - I just want to learn something new.
Henrik
29-May-2010
[3199]
yes, the big disadvantage is that once you get used to REBOL, most 
other languages become painful to work with.
florin
29-May-2010
[3200]
java/groovy background - you see how diferent rebol can be to me. 
After righting a practical script and reading the Core manual, I 
thing rebol for me could become a rather practical tool for day to 
day tasks . I will see what it takes to write larger apps with it. 
I''m curious at this time.
Henrik
29-May-2010
[3201]
I'm not a Java guy, but REBOL to me feels like a language that is 
doing what Java should have been doing all along.
florin
29-May-2010
[3202x2]
When you say "Java should've been doing" you're saying Java should've 
been something else than Java. It's just very different. I still 
enjoy the static nature of java and the expressiveness of groovy. 
Rebol is interesting because of its conciseness and great practicality. 
Lots of data types makes sense in this context. The multitude of 
refinements provide a great deal of syntactical help. I'll enjoy 
this trip.
if cheyenne / rsp was more involved as a modern web framework, I'd 
start using rebol for we development today.
Henrik
29-May-2010
[3204x2]
I was think about the cross-platform aspect of Java.
thinking
florin
29-May-2010
[3206]
Is there any web framework out there that I missed?
NickA
29-May-2010
[3207]
MakeDoc and its variants?
florin
29-May-2010
[3208x2]
Is MakeDoc a rebol framework? Or is it a python one?
http://www.robertmuench.de/projects/mdp/?
Henrik
29-May-2010
[3210x2]
makedoc is a document generator. I'm not sure you would call it a 
framework.
there are many variants of it
GiuseppeC
29-May-2010
[3212]
Just a question for REBOL School for me too: is there a way to send 
HTML emails with embedded images ?
florin
29-May-2010
[3213]
I'm totally green to this. I've seen images imbedded into rebol source 
files. Could this be helpful?

http://www.rebol.net/cookbook/recipes/0048.html
amacleod
29-May-2010
[3214x2]
I do not think so...Images are always links in emails...one reason 
I avoid them as, like me, most clients require you to manually load 
them for security issues.


The link above is just to embed them in a rebol script. I do not 
think there is a similar method for html...
Correction...here is a link that might help: http://rifers.org/blogs/gbevin/2005/4/11/embedding_images_inside_html
Pekr
30-May-2010
[3216]
it is not true images rea always links in email - you can embedd 
images too .... postcard services do so ...
Gabriele
30-May-2010
[3217]
Giuseppe, basically, you attach the image with the email, and use 
a normal <img> tag in the HTML with a cid: URL. i don't have an example 
at hand, unfortunately...
Reichart
30-May-2010
[3218]
You should be able to take an HTML with an image in it, look at the 
source, and then spew that out of REBOL.
BudzinskiC
30-May-2010
[3219]
What amacleoud suggested should work just fine. Although maybe not 
in all mail clients. I do know that Adobe Air for example doesn't 
allow data links (for security reasons IIRC) so maybe some email 
apps have deactivated that feature too. It does work fine on my iPod 
Touch's email client (which is the only client I could test this 
on since I usually just use Gmail's web interface). Here's a small 
rebol script that does the job (yeah, I was bored)

REBOL []
imgfile: request-file/only
encoded: enbase read/binary imgfile
filetype: next to-string suffix? imgfile
; you can use this right in the browser as a web address
datalink: rejoin [{data:image/} filetype ";base64," encoded]
; and this inside html source
imglink: rejoin [{<img src="} datalink {"/>}]
editor imglink
amacleod
30-May-2010
[3220]
nice little script...i got errrors when I tried to copy and paste. 
Thanks.
Gabriele
31-May-2010
[3221]
Reichart, actually, that is true only if the HTML comes from an email 
with an embedded image (as attachment, not as link to an external 
website), and you need to look at the whole message source rather 
than just the HTML to make sense of it. the cid: links are an email 
thing and have nothing to do with HTML itself.
BudzinskiC
31-May-2010
[3222]
amacleod: Worked fine for me but I only tried it with a very small 
picture (the rebol logo actually), if you tried a big picture the 
resulting data link might be just too long for copy & paste actions 
(really long text almost always causes problems). Just replace the 
last line (editor imglink) with

write %somefile.html imglink
browse %somefile.html

And it "should" work with bigger pictures.
amacleod
31-May-2010
[3223x3]
Thanks BudzinskiC,

Works for me in Outlook 
but not Google mail web interface....
but it works on my palm pre accessing my gmail account
I was able to embed a picture using outlook and it worked in gmail 
web mail...

What method does outlook use to embed images?
image is referenced in this code but where is the image? is it somehow 
attached but not seen as an attachment?


<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><img width=688 height=155 id="_x0000_i1025"

src="cid:[image001-:-jpg-:-01CB00A8-:-DF6F9A50]"><o:p></o:p></span></font></p>
GiuseppeC
31-May-2010
[3226]
I admit I am a bit confused...
Gabriele
1-Jun-2010
[3227]
Amacleod, the image is attached, the container is multipart/related 
instead of multipart/mixed. The email client will not show the individual 
components of a multipart/related message, instead, it shows the 
main part (the HTML) which then refers to the other parts (in case 
of HTML, using cid: links).
amacleod
1-Jun-2010
[3228]
is there a way for rebol to attach multipert/related?
Oldes
1-Jun-2010
[3229x3]
You can check this really old script http://box.lebeda.ws/~hmm/rebol/mail-page_latest.r
But I'm not sure if it works. I never used it in real situation.
Just quicklu checking and it does not look like good example. It's 
probably some not working version. Found several bugs just by observing.
I've reuploaded the file so at least this test works:

write/binary %test.msg page-mailer/form-msg page-mailer/make-html-mail/text 
{ahoj <img src="path-to-your-image.jpg">} {plain version}


Which produces MSG file which you can examine to see, how it should 
looks like. For example like this one:
http://box.lebeda.ws/~hmm/rebol/test.msg
Claude
1-Jun-2010
[3232x5]
hi here you are un function to send mail with multi attachments
REBOL[]


send: func [
	"Send a message to an address (or block of addresses)"
	;Note - will also be used with REBOL protocol later.
	address [email! block!] "An address or block of addresses"
	message "Text of message. First line is subject."
	/only   "Send only one message to multiple addresses"
	/header "Supply your own custom header"
	header-obj [object!] "The header to use"
	/attach "Attach file, files, or [.. [filename data]]"
	files [file! block!] "The files to attach to the message"
	/subject "Set the subject of the message"
	subj "The subject line"
	/show "Show all recipients in the TO field"
	/local smtp-port boundary make-boundary tmp from
][
	make-boundary: does []

	if file? files [files: reduce [files]] ; make it a block
	if email? address [address: reduce [address]] ; make it a block
	message: either string? message [copy message] [mold message]

	if not header [                 ; Clone system default header
		header-obj: make system/standard/email [

   subject: any [subj copy/part message any [find message newline 50]]
		]
	]
	if subject [header-obj/subject: subj]
	either none? header-obj/from [

  if none? header-obj/from: from: system/user/email [net-error "Email 
  header not set: no from address"]
		if all [string? system/user/name not empty? system/user/name][
			header-obj/from: rejoin [system/user/name " <" from ">"]
		]
	][
		from: header-obj/from
	]
	if none? header-obj/to [
		header-obj/to: tmp: make string! 20
		if show [
			foreach email address [repend tmp [email ", "]]
			clear back back tail tmp
		]
	]
	if none? header-obj/date [header-obj/date: to-idate now]

	if attach [

  boundary: rejoin ["--__REBOL--" system/product "--" system/version 
  "--" checksum form now/precise "__"]
		header-obj/MIME-Version: "1.0"

  header-obj/content-type: join "multipart/mixed; boundary=" [{"} skip 
  boundary 2 {"}]
		message: build-attach-body message files boundary
	]

	;-- Send as an SMTP batch or individually addressed:
	smtp-port: open [scheme: 'esmtp]
	either only [ ; Only one message to multiple addrs
		address: copy address
		; remove non-email values
		remove-each value address [not email? :value]

  message: head insert insert tail net-utils/export header-obj newline 
  message
		insert smtp-port reduce [from address message]
	] [
		foreach addr address [
			if email? addr [
				if not show [insert clear header-obj/to addr]

    tmp: head insert insert tail net-utils/export header-obj newline 
    message
				insert smtp-port reduce [from reduce [addr] tmp]
			]
		]
	]
	close smtp-port
]

resend: func [
	"Relay a message"
	to from message /local smtp-port
][
	smtp-port: open [scheme: 'esmtp]
	insert smtp-port reduce [from reduce [to] message]
	close smtp-port
]

build-attach-body: function [
	{Return an email body with attached files.}
	body [string!] {The message body}

 files [block!] {List of files to send [%file1.r [%file2.r "data"]]}
	boundary [string!] {The boundary divider}
][
	make-mime-header
	break-lines
	file
	val
][
	make-mime-header: func [file] [
		net-utils/export context [

   Content-Type: join {application/octet-stream; name="} [file {"}]
			Content-Transfer-Encoding: "base64"

   Content-Disposition: join {attachment; filename="} [file {"^/}]
		]
	]
	break-lines: func [mesg data /at num] [
		num: any [num 72]
		while [not tail? data] [
			append mesg join copy/part data num #"^/"
			data: skip data num
		]
		mesg
	]
	if not empty? files [
		insert body reduce [boundary "^/Content-type: text/html^/^/"]
		append body "^/^/"
		if not parse files [
			some [
				(file: none)
				[
					set file file! (val: read/binary file)
					| into [
						set file file!
						set val skip ;anything allowed
						to end
					]
				] (
					if file [
						repend body [
							boundary "^/"
							make-mime-header any [find/last/tail file #"/" file]
						]
						val: either any-string? val [val] [mold :val]
						break-lines body enbase val
					]
				)
			]
		] [net-error "Cannot parse file list."]
		append body join boundary "--^/"
	]
	body
]
i find it on http://www.rebol.org/
do %./send.r

header: make system/standard/email [
        Subject:  rejoin ["example REBOL "]
        Organization: ""
        Content-Type: "multipart/html"
]


msg: rejoin [
{<img src = "test.jpg" /> </html>}



]

send/header/attach [[cr-:-fideurambank-:-lu]] msg header [%test.jpg]
with this you can send mail with images in html
amacleod
1-Jun-2010
[3237]
Nice Claude! I'll check it out. Thanks.
GiuseppeC
1-Jun-2010
[3238]
Thanks Claude, I'll try to use this too.
Davide
1-Jun-2010
[3239]
To display the image inline the header "Content-ID" is mandatory. 
So add something like:

Content-ID: rejoin ["<" file ">"]


And use that id to reference the image in html, prefixed with string 
"cid:" 

<img src="cid:test.jpg" />
PatrickP61
23-Sep-2010
[3240]
I want to capture only  the function names in a block and write it 
to a file.

The WHAT function does this by printing a list of function names 
and then a short description.
I tried this:

data: to-block what


** Script error: to-block does not allow unset! for its value argument

How can I just capture the Function names in a block using WHAT?
Graham
23-Sep-2010
[3241]
have a look at the source of 'what and modify it?
PatrickP61
23-Sep-2010
[3242]
that is a possibility of course, but I thought there would be a faster 
way of just capturing the printed output into a blcok
Gregg
23-Sep-2010
[3243]
Unfortunately some functions, like WHAT, weren't designed with that 
in mind.
Chris
23-Sep-2010
[3244]
You can use 'echo to capture the result in a temporary file, then 
delete the file after:

	echo %tmp.txt
	what
	echo none
	parse read %tmp.txt [...]
	delete %tmp.txt

Shame you can't echo to a string or binary...
PatrickP61
23-Sep-2010
[3245]
Chris, That is a good idea, for the quick and dirty, but I am having 
an issue with WHAT

WHAT has what is supposed to be an optional field for module name 
that follows it.  But if I do this:

	echo %tmp.txt
	what
	echo none

This is processed as if it was this:

	echo %tmp.txt

 what echo               <--- echo becomes the passed parameter into 
 WHAT
	none


How do I get around that other than specifying a dummy field?  Try 
this:

	echo %tmp.txt
	what

 halt		<--- halt will NOT be executed since it is pulled into the 
 WHAT function!!
	echo none
BrianH
23-Sep-2010
[3246]
It's only optional from the command line, not within a script.