[guadec-web-regcfp/develop] Split long names over two lines



commit 4c45a8cc3e2b825624ca3d3ae859c7305a259968
Author: Patrick Uiterwijk <puiterwijk redhat com>
Date:   Fri Aug 7 07:20:34 2015 +0200

    Split long names over two lines

 routes/desk.js           |   44 +++++++++++++++++++++++++++++++++++---------
 views/desk/badge_svg.hbs |   16 ++++++++--------
 2 files changed, 43 insertions(+), 17 deletions(-)
---
diff --git a/routes/desk.js b/routes/desk.js
index 5a0e68f..c2782e0 100644
--- a/routes/desk.js
+++ b/routes/desk.js
@@ -135,17 +135,43 @@ router.get('/badge', function(req, res, next) {
     .then(function(rega) {
       Registration.findOne({where: {id:regidb}, include: [User]})
         .then(function(regb) {
-          var rega_name = "";
-          var regb_name = "";
-          if(!!rega) {
-            rega_name = rega.User.name;
-          }
-          if(!!regb) {
-            regb_name = regb.User.name;
+          var regs = {
+            a: rega,
+            b: regb
+          };
+          var names = {
+            a: {
+              name: "",
+              longname: ""
+            },
+            b: {
+              name: "",
+              longname: ""
+            }
+          };
+          for(reg in regs) {
+            if(!!regs[reg]) {
+              var name = regs[reg].User.name;
+              var longname = "";
+              if(name.length > 20) {
+                snames = name.split(' ');
+                name = '';
+                for(var tname in snames) {
+                  tname = snames[tname];
+                  if(name.length > 20) {
+                    longname += tname + ' ';
+                  } else {
+                    name += tname + ' ';
+                  }
+                }
+              }
+              console.log('Setting reg: ' + reg);
+              names[reg]['name'] = name;
+              names[reg]['longname'] = longname;
+            }
           }
           req.app.render('desk/badge_svg', {
-              rega_name: rega_name,
-              regb_name: regb_name,
+              names: names,
               layout: false
           }, function(err, html) {
             if(!!err) {
diff --git a/views/desk/badge_svg.hbs b/views/desk/badge_svg.hbs
index 8439538..67c639a 100644
--- a/views/desk/badge_svg.hbs
+++ b/views/desk/badge_svg.hbs
@@ -2421,7 +2421,7 @@
              x="-392.84854"
              y="73.731468"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic'"
-             id="tspan8265">{{regb_name}}</tspan></tspan></text>
+             id="tspan8265">{{names.b.name}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -2437,7 +2437,7 @@
              x="-131.1073"
              y="73.031914"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic';fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1"
-             id="tspan8271">{{regb_name}}</tspan></tspan></text>
+             id="tspan8271">{{names.b.name}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -2453,7 +2453,7 @@
              x="131.40047"
              y="72.330284"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic';fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1"
-             id="tspan8277">{{rega_name}}</tspan></tspan></text>
+             id="tspan8277">{{names.a.name}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
@@ -2469,7 +2469,7 @@
              x="-392.79364"
              y="94.260193"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic'"
-             id="tspan8265-3">{{regb_longname}}</tspan></tspan></text>
+             id="tspan8265-3">{{names.b.longname}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
@@ -2485,7 +2485,7 @@
              x="-131.05243"
              y="93.560638"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic';fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1"
-             id="tspan8271-6">{{regb_longname}}</tspan></tspan></text>
+             id="tspan8271-6">{{names.b.longname}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
@@ -2501,7 +2501,7 @@
              x="131.45535"
              y="92.859009"
              
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;font-family:'URW
 Gothic';-inkscape-font-specification:'URW Gothic';fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1"
-             id="tspan8277-1">{{rega_longname}}</tspan></tspan></text>
+             id="tspan8277-1">{{names.a.longname}}</tspan></tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:Calibri;-inkscape-font-specification:Calibri;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new"
@@ -2514,7 +2514,7 @@
            x="393.49655"
            y="71.629791"
            id="tspan8275-9"
-           style="font-size:17.5px;-inkscape-font-specification:'URW Gothic';font-family:'URW 
Gothic';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal">{{rega_name}}</tspan></text>
+           style="font-size:17.5px;-inkscape-font-specification:'URW Gothic';font-family:'URW 
Gothic';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal">{{names.a.name}}</tspan></text>
       <text
          xml:space="preserve"
          
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14px;line-height:125%;font-family:'URW
 Gothic';-inkscape-font-specification:'URW 
Gothic';text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;enable-background:new;"
@@ -2527,7 +2527,7 @@
            x="393.55142"
            y="92.158516"
            id="tspan8275-4-6"
-           style="font-size:17.5px;-inkscape-font-specification:'URW Gothic';font-family:'URW 
Gothic';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">{{rega_longname}}</tspan></text>
+           style="font-size:17.5px;-inkscape-font-specification:'URW Gothic';font-family:'URW 
Gothic';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;">{{names.a.longname}}</tspan></text>
     </g>
   </g>
 </svg>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]