Templatize email list interface.
authorWilfried Goesgens <willi@arangodb.com>
Mon, 16 Nov 2015 21:38:47 +0000 (22:38 +0100)
committerWilfried Goesgens <willi@arangodb.com>
Mon, 16 Nov 2015 21:38:47 +0000 (22:38 +0100)
12 files changed:
webcit/static/t/vcard/list.html [new file with mode: 0644]
webcit/static/t/vcard/list/cell_end.html [new file with mode: 0644]
webcit/static/t/vcard/list/empty.html [new file with mode: 0644]
webcit/static/t/vcard/list/head.html [new file with mode: 0644]
webcit/static/t/vcard/list/internal_error.html [new file with mode: 0644]
webcit/static/t/vcard/list/item.html [new file with mode: 0644]
webcit/static/t/vcard/list/name.txt [new file with mode: 0644]
webcit/static/t/vcard/list/row_end.html [new file with mode: 0644]
webcit/static/t/vcard/list/row_start.html [new file with mode: 0644]
webcit/static/t/vcard/list/section_end.html [new file with mode: 0644]
webcit/static/t/vcard/list/section_start.html [new file with mode: 0644]
webcit/vcard_edit.c

diff --git a/webcit/static/t/vcard/list.html b/webcit/static/t/vcard/list.html
new file mode 100644 (file)
index 0000000..531530b
--- /dev/null
@@ -0,0 +1 @@
+<?ITERATE("MAIL:VCARDS", ="vcard_list_item")> 
diff --git a/webcit/static/t/vcard/list/cell_end.html b/webcit/static/t/vcard/list/cell_end.html
new file mode 100644 (file)
index 0000000..9d58dda
--- /dev/null
@@ -0,0 +1 @@
+<td>&nbsp;</td>
diff --git a/webcit/static/t/vcard/list/empty.html b/webcit/static/t/vcard/list/empty.html
new file mode 100644 (file)
index 0000000..8b4583a
--- /dev/null
@@ -0,0 +1,4 @@
+<br><br><br><div align="center"><i>
+<?_("This address book is empty.")>
+</i></div>
+
diff --git a/webcit/static/t/vcard/list/head.html b/webcit/static/t/vcard/list/head.html
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/webcit/static/t/vcard/list/internal_error.html b/webcit/static/t/vcard/list/internal_error.html
new file mode 100644 (file)
index 0000000..0a8f141
--- /dev/null
@@ -0,0 +1,3 @@
+<br><br><br><div align="center"><i>
+<?_("An internal error has occurred.")>
+</i></div>
diff --git a/webcit/static/t/vcard/list/item.html b/webcit/static/t/vcard/list/item.html
new file mode 100644 (file)
index 0000000..030fced
--- /dev/null
@@ -0,0 +1,8 @@
+<?!("COND:ITERATE:ISMOD", 10, #"NAMESPERPAGE", 0)><?=("vcard_list_section_start")><??("X", 10)>
+<?!("COND:ITERATE:ISMOD", 20, 4, 0)> <?=("vcard_list_row_start")><??("X", 20)>
+
+<td><a href='readfwd?startmsg=<?VC:MSGNO()>?is_singlecard=1?maxmsgs=1?is_summary=0?alpha=<?BSTR("alpha")>'><?VC:ITEM(#"VC:.n.last", "X")> <?VC:ITEM(#"VC:.n.first", "X")><?VC:ITEM(#"VC:.n.middle", "X")>;<?VC:ITEM(#"VC:.n.prefix", "X")>;<?VC:ITEM(#"VC:.n.suffix", "X")></a></td>
+
+<??("COND:ITERATE:FIRSTN", 30)><?!("COND:ITERATE:ISMOD", 35, 4, 3)> <?=("vcard_list_row_end")><??("X", 35)><?!("X", 30)>
+
+<??("COND:ITERATE:FIRSTN", 40)><?!("COND:ITERATE:ISMOD", 45, 59, 0)><?=("vcard_list_section_end")><??("X", 40)><??("X",45)>
diff --git a/webcit/static/t/vcard/list/name.txt b/webcit/static/t/vcard/list/name.txt
new file mode 100644 (file)
index 0000000..e210fe2
--- /dev/null
@@ -0,0 +1 @@
+<?VC:ITEM(#"VC:.n.last", "")>;<?VC:ITEM(#"VC:.n.first", "")>;<?VC:ITEM(#"VC:.n.middle", "")>;<?VC:ITEM(#"VC:.n.prefix", "")>;<?VC:ITEM(#"VC:.n.suffix", "")>
diff --git a/webcit/static/t/vcard/list/row_end.html b/webcit/static/t/vcard/list/row_end.html
new file mode 100644 (file)
index 0000000..df16534
--- /dev/null
@@ -0,0 +1 @@
+</tr><!-- rowend -->
diff --git a/webcit/static/t/vcard/list/row_start.html b/webcit/static/t/vcard/list/row_start.html
new file mode 100644 (file)
index 0000000..b997a13
--- /dev/null
@@ -0,0 +1 @@
+<tr bgcolor='<?%("COND:ITERATE:ISMOD", 10, 8, 0, "#dddddd", "#ffffff")>'>
diff --git a/webcit/static/t/vcard/list/section_end.html b/webcit/static/t/vcard/list/section_end.html
new file mode 100644 (file)
index 0000000..ae9ebb5
--- /dev/null
@@ -0,0 +1,3 @@
+</table> <!-- sectionend -->
+</div>
+<!-- end tab <?ITERATE:N:DIV(#"NAMESPERPAGE")> of 10 -->
diff --git a/webcit/static/t/vcard/list/section_start.html b/webcit/static/t/vcard/list/section_start.html
new file mode 100644 (file)
index 0000000..4d9d5b0
--- /dev/null
@@ -0,0 +1,5 @@
+<!-- begin tab <?ITERATE:N:DIV(#"NAMESPERPAGE")> of 10 -->
+<div id="tabdiv<?ITERATE:N:DIV(#"NAMESPERPAGE")>" style='display:<?%("COND:ITERATE:FIRSTN", 1, 0, 0, "block", "none")>' class="tabcontent" >
+<table border="0" cellspacing="0" cellpadding="3" width="100%"><!--section start-->
+
+
index a34336c417d3b29fca5206f0043912174766def3..975ea239f0f203783d33fda4b6ef7a43d3778522 100644 (file)
@@ -111,12 +111,15 @@ typedef struct _addrbookent {
        StrBuf *name;
        HashList *VC;
        long ab_msgnum;         /* message number of address book entry */
+       StrBuf *msgNoStr;
 } addrbookent;
 
 void deleteAbEnt(void *v) {
        addrbookent *vc = (addrbookent*)v;
        DeleteHash(&vc->VC);
        FreeStrBuf(&vc->name);
+       FreeStrBuf(&vc->msgNoStr);
+       free(vc);
 }
 
 HashList *DefineToToken = NULL;
@@ -272,6 +275,15 @@ void tmpl_vcard_name_str(StrBuf *Target, WCTemplputParams *TP)
        }
 }
 
+void tmpl_vcard_msgno(StrBuf *Target, WCTemplputParams *TP)
+{
+       addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+       if (ab->msgNoStr == NULL) {
+               ab->msgNoStr = NewStrBufPlain(NULL, 64);
+       }
+       StrBufPrintf(ab->msgNoStr, "%ld", ab->ab_msgnum);
+       StrBufAppendTemplate(Target, TP, ab->msgNoStr, 0);
+}
 void tmpl_vcard_context_name_str(StrBuf *Target, WCTemplputParams *TP)
 {
        void *vItem;
@@ -667,6 +679,12 @@ void tmplput_VCARD_ITEM(StrBuf *Target, WCTemplputParams *TP)
        
 }
 
+HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
+{
+       HashList *pb = CTX(CTX_VCARD_LIST);
+       return pb;
+}
+
 void display_one_vcard (StrBuf *Target, addrbookent *ab, const char *tp_name, size_t tp_name_len)
 {
        WCTemplputParams *TP = NULL;
@@ -727,7 +745,7 @@ void do_edit_vcard(long msgnum, char *partnum,
                   wc_mime_attachment *VCAtt,
                   const char *return_to, 
                   const char *force_room) {
-       HashList *VC;   WCTemplputParams SubTP;
+       WCTemplputParams SubTP;
        wcsession *WCC = WC;
        message_summary *Msg = NULL;
        wc_mime_attachment *VCMime = NULL;
@@ -764,7 +782,7 @@ void do_edit_vcard(long msgnum, char *partnum,
                        v = VCardLoad(VCAtt->Data);
                }
 
-               parse_vcard(WCC->WBuf, v, VC, NULL);
+               parse_vcard(WCC->WBuf, v, ab.VC, NULL);
        
        
                vcard_free(v);
@@ -1053,16 +1071,16 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
  * addrbook    the addressbook to render
  * num_ab      the number of the addressbook
  */
+static int NAMESPERPAGE = 60;
 void do_addrbook_view(vcardview_struct* VS) {
        long i = 0;
        int displayed = 0;
        int bg = 0;
-       static int NAMESPERPAGE = 60;
        int num_pages = 0;
        int tabfirst = 0;
        int tablast = 0;
        int page = 0;
-       char **tablabels;
+       const char **tablabels;
        int num_ab = GetCount(VS->addrbook);
        HashList *headlines;
        HashPos *it;
@@ -1114,12 +1132,19 @@ void do_addrbook_view(vcardview_struct* VS) {
                                StrBufAppendBuf(headline, a2->name, 0);
                        }
                }
+               tablabels[i] = ChrPtr(headline);
                Put(headlines, LKEY(i), headline, HFreeStrBuf);
        }
 
        tabbed_dialog(num_pages, tablabels);
        page = (-1);
 
+
+       StackContext(TP, &SubTP, VS->addrbook, CTX_VCARD_LIST, 0, NULL);
+
+       DoTemplate(HKEY("vcard_list"), WCC->WBuf, &SubTP);
+       UnStackContext(&SubTP);
+/*
        it = GetNewHashPos(VS->addrbook, 0);
        for (i=0; i<num_ab; ++i) {
                void *v;
@@ -1130,7 +1155,7 @@ void do_addrbook_view(vcardview_struct* VS) {
                if (v == NULL)
                        continue;
                abEnt = (addrbookent *) v;
-               if ((i / NAMESPERPAGE) != page) {       /* New tab */
+               if ((i / NAMESPERPAGE) != page) {       / * New tab * /
                        page = (i / NAMESPERPAGE);
                        if (page > 0) {
                                do_template("vcard_list_section_end");
@@ -1158,7 +1183,7 @@ void do_addrbook_view(vcardview_struct* VS) {
                ++displayed;
        }
        DeleteHashPos(&it);
-
+*/
        /* Placeholders for empty columns at end */
        if ((num_ab % 4) != 0) {
                for (i=0; i<(4-(num_ab % 4)); ++i) {
@@ -1174,6 +1199,7 @@ void do_addrbook_view(vcardview_struct* VS) {
        end_tab(num_pages, num_pages);
 
        DeleteHash(&headlines);
+       free(tablabels);
        wDumpContent(1);
 }
 
@@ -1284,6 +1310,9 @@ InitModule_VCARD
        autoRegisterTokens(&VCEnumCounter, VCStrE, Prefix, 0, 0);
        FreeStrBuf(&Prefix);
 
+       REGISTERTokenParamDefine(NAMESPERPAGE);
+
+
        RegisterCTX(CTX_VCARD);
        RegisterCTX(CTX_VCARD_LIST);
        RegisterCTX(CTX_VCARD_TYPE);
@@ -1297,6 +1326,10 @@ InitModule_VCARD
                vcard_LoadMsgFromServer,
                vcard_RenderView_or_Tail,
                vcard_Cleanup);
+
+       RegisterIterator("MAIL:VCARDS", 0, NULL, CtxGetVcardList, NULL, NULL, CTX_VCARD, CTX_VCARD_LIST, IT_NOFLAG);
+
+
        WebcitAddUrlHandler(HKEY("edit_vcard"), "", 0, edit_vcard, 0);
        WebcitAddUrlHandler(HKEY("submit_vcard"), "", 0, submit_vcard, 0);
        WebcitAddUrlHandler(HKEY("vcardphoto"), "", 0, display_vcard_photo_img, NEED_URL);
@@ -1304,6 +1337,7 @@ InitModule_VCARD
        RegisterNamespace("VC:ITEM", 2, 2, tmpl_vcard_item, preeval_vcard_item, CTX_VCARD);
        RegisterNamespace("VC:CTXITEM", 1, 1, tmpl_vcard_context_item, NULL, CTX_VCARD_TYPE);
        RegisterNamespace("VC:NAME", 1, 1, tmpl_vcard_name_str, preeval_vcard_name_str, CTX_VCARD);
+       RegisterNamespace("VC:MSGNO", 0, 1, tmpl_vcard_msgno, NULL, CTX_VCARD);
        RegisterNamespace("VC:CTXNAME", 1, 1, tmpl_vcard_context_name_str, NULL, CTX_VCARD_TYPE);
        REGISTERTokenParamDefine(FlatString);
        REGISTERTokenParamDefine(StringCluster);