message_as_html

NAML documentation   Watch a video
   Usages of this macro
... in message_as_html.naml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<override_macro name="message_as_html" requires="message">
    <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.either
Binary
Namespace: BasicNamespace
Parameters: condition1, condition2
 condition1="[n.is_deleted
Binary
Namespace: MessageNamespace
/]" condition2="[n.is_deactivated
Binary
Namespace: MessageNamespace
/]">
        <then>
            <b><t>CONTENTS DELETED</t></b>
            <div class="weak-color"><t>The author has deleted this message.</t></div>
        </then>
        <else>
            <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="output">
                <n.as_html_list
Binary
Namespace: MessageNamespace
Parameters: do
.process_message_html
Macro
Requires: html_list
 />
            </n.set_var.>
            
            <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.is_imported_mail
Binary
Namespace: MessageNamespace
>
                <then>
                    <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="output">
                        <n.remove_unsubscription_link
Macro
Parameters: html
.var
Binary
Namespace: BasicNamespace
Parameters: name
 name="output" />
                    </n.set_var.>                
                    
                    <n.comment
Macro
Parameters: text
>
                        PART 1: Copy the attachment links to a variable
                    </n.comment>
                    <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="attachments">                
                        <n.regex
Binary
Namespace: BasicNamespace
Parameters: pattern, text, do
. text="[n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='output'/]" pattern="[n.attachments_regex
Macro
/]">
                            <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.find
Binary
Namespace: RegexNamespace
>
                                <then.found
Binary
Namespace: RegexNamespace
Parameters: group
/>
                            </n.if.find>
                        </n.regex.>                
                    </n.set_var.>          
                   
                    <n.regex
Binary
Namespace: BasicNamespace
Parameters: pattern, text, do
. text="[n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='attachments'/]" pattern="[n.href_regex
Macro
/]">
                        <n.loop
Macro
Requires: sequence
Parameters: by, do
.>                   
                            <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="thumb_url">                                   
                                 <n.regex
Binary
Namespace: BasicNamespace
Parameters: pattern, text, do
. text="[n.current_element
Binary
Namespace: RegexNamespace
/]" pattern="[n.href_regex_wIMG
Macro
/]">
                                     <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.find
Binary
Namespace: RegexNamespace
>
                                         <then >
                                             src= <n.regex_replace_all
Binary
Namespace: BasicNamespace
Parameters: pattern, text, replacement
 text ="[n.current_element
Binary
Namespace: RegexNamespace
/]" pattern="href=" replacement =''/>
                                height="250px" \>
 
                                         </then>
                                         <else>
                                             src="http://forum.sudsol.org/images/icon_attachment.gif"
                                         </else>
                                     </n.if.find>
                                 </n.regex.> 
                            </n.set_var.>  
 
                            <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="attachments">                
                                <n.regex_replace_first
Binary
Namespace: BasicNamespace
Parameters: pattern, text, replacement
 text ="[n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='attachments'/]" pattern="[n.img_regex
Macro
/]" replacement ="[n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='thumb_url'/]"/>  
                            </n.set_var.>
                        
                            
                        </n.loop.>
                    </n.regex.>  
                    
                    <n.comment
Macro
Parameters: text
>
                        PART 2: Rebuild the "output" variable by placing the attachments at the top.
                        At the end, we remove the old attachments so that we don't show duplicate links.
                    </n.comment>
                    <n.set_var
Binary
Namespace: BasicNamespace
Parameters: name, value
. name="output">
                        <div id ="attachments">
                        <n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='attachments' />
                        </div>
                        <br/>
                        <n.regex_replace_all
Binary
Namespace: BasicNamespace
Parameters: pattern, text, replacement
 text ="[n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name='output'/]" pattern="[n.attachments_regex
Macro
/]" replacement ='' />
                    </n.set_var.>                                           
                    
                </then>                    
            </n.if.is_imported_mail>
            <n.var
Binary
Namespace: BasicNamespace
Parameters: name
 name="output" />
        </else>
    </n.if.either>
</override_macro>
Overrides default macro
... in message.naml
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<macro name="message_as_html" requires="message">
    <n.if.either condition1="[n.is_deleted/]" condition2="[n.is_deactivated/]">
        <then>
            <b><t>CONTENTS DELETED</t></b>
            <div class="weak-color"><t>The author has deleted this message.</t></div>
        </then>
        <else>
            <n.set_var. name="output">
                <n.as_html_list.process_message_html />
            </n.set_var.>
            <n.if.is_imported_mail>
                <then.set_var. name="output">
                    <n.remove_unsubscription_link.var name="output" />
                </then.set_var.>
            </n.if.is_imported_mail>
            <n.var name="output" />
        </else>
    </n.if.either>
</macro>