<commit_before>import "babel-polyfill";

self.addEventListener("push", async event => {
  console.debug("push event");
  const payload = event.data.json();
  const clientWindows = await self.clients.matchAll({ type: "window" });
  const activeWindows = clientWindows.filter(client => {
    return client.focused;
  });

  if (activeWindows.length == 0) {
    switch (payload.type) {
      case "CONNECT":
        self.registration.showNotification("New Conversation!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-connect",
          icon: payload.icon,
          body: payload.message,
        });
        break;
      case "MESSAGE":
        self.registration.showNotification("New message!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-message",
          icon: payload.icon,
          body: payload.message,
        });
        break;
      case "HINT":
        self.registration.showNotification("New Match!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-hint",
          icon: payload.icon,
        });
        break;
    }
  }
});

self.addEventListener("notificationclick", event => {
  event.waitUntil(openNotifiedPage(event)); //This is needed so that the browser allows us to open/focus a window
});

async function openNotifiedPage(event) {
  console.log(event.notification.data);
  const connectionUri = event.notification.data.connectionUri;
  const type = event.notification.data.type;
  const atomUri = event.notification.data.atomUri;
  const clientWindows = await self.clients.matchAll({ type: "window" });
  const urlWindows = clientWindows.filter(client => {
    const [, clientQuery] = client.url.split("?");
    const param = new URLSearchParams(clientQuery).get("connectionUri");
    console.log(param);
    return param == connectionUri;
  });
  console.log(clientWindows.map(client => client.url));
  const inventoryWindows = clientWindows.filter(client => {
    const genericUris = [
      `${self.registration.scope}#!/inventory`,
      `${self.registration.scope}#!/connections`,
    ];
    return genericUris.find(uri => client.url.startsWith(uri)) !== undefined;
  });
  const targetUri =
    type === "HINT"
      ? `${
          self.registration.scope
        }#!/post/?postUri=${atomUri}&viewConnUri=${connectionUri}`
      : `${
          self.registration.scope
        }#!/connections?connectionUri=${connectionUri}`;
  console.log(targetUri);

  if (urlWindows.length > 0) {
    const activeWindows = urlWindows.filter(client => client.focused);
    if (activeWindows.length == 0) {
      urlWindows[0].focus();
    }
  } else if (inventoryWindows.length > 0) {
    const activeWindows = inventoryWindows.filter(client => client.focused);
    let targetWindow;
    if (activeWindows.length > 0) {
      targetWindow = activeWindows[0];
    } else {
      targetWindow = inventoryWindows[0];
      targetWindow.focus();
    }
    targetWindow.navigate(targetUri);
  } else {
    self.clients.openWindow(targetUri);
  }
}
<commit_msg>Remove deeplink into connection b/c of #2985<commit_after>import "babel-polyfill";

self.addEventListener("push", async event => {
  console.debug("push event");
  const payload = event.data.json();
  const clientWindows = await self.clients.matchAll({ type: "window" });
  const activeWindows = clientWindows.filter(client => {
    return client.focused;
  });

  if (activeWindows.length == 0) {
    switch (payload.type) {
      case "CONNECT":
        self.registration.showNotification("New Conversation!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-connect",
          icon: payload.icon,
          body: payload.message,
        });
        break;
      case "MESSAGE":
        self.registration.showNotification("New message!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-message",
          icon: payload.icon,
          body: payload.message,
        });
        break;
      case "HINT":
        self.registration.showNotification("New Match!", {
          data: {
            atomUri: payload.atomUri,
            connectionUri: payload.connectionUri,
            type: payload.type,
          },
          tag: "won-hint",
          icon: payload.icon,
        });
        break;
    }
  }
});

self.addEventListener("notificationclick", event => {
  event.waitUntil(openNotifiedPage(event)); //This is needed so that the browser allows us to open/focus a window
});

async function openNotifiedPage(event) {
  console.log(event.notification.data);
  const connectionUri = event.notification.data.connectionUri;
  const type = event.notification.data.type;
  const atomUri = event.notification.data.atomUri;
  const clientWindows = await self.clients.matchAll({ type: "window" });
  const urlWindows = clientWindows.filter(client => {
    const [, clientQuery] = client.url.split("?");
    const param = new URLSearchParams(clientQuery).get("connectionUri");
    console.log(param);
    return param == connectionUri;
  });
  console.log(clientWindows.map(client => client.url));
  const inventoryWindows = clientWindows.filter(client => {
    const genericUris = [
      `${self.registration.scope}#!/inventory`,
      `${self.registration.scope}#!/connections`,
    ];
    return genericUris.find(uri => client.url.startsWith(uri)) !== undefined;
  });
  const targetUri =
    type === "HINT"
      ? `${self.registration.scope}#!/post/?postUri=${atomUri}` // when deeplink works, append &viewConnUri=${connectionUri}` see https://github.com/researchstudio-sat/webofneeds/issues/2985
      : `${
          self.registration.scope
        }#!/connections?connectionUri=${connectionUri}`;
  console.log(targetUri);

  if (urlWindows.length > 0) {
    const activeWindows = urlWindows.filter(client => client.focused);
    if (activeWindows.length == 0) {
      urlWindows[0].focus();
    }
  } else if (inventoryWindows.length > 0) {
    const activeWindows = inventoryWindows.filter(client => client.focused);
    let targetWindow;
    if (activeWindows.length > 0) {
      targetWindow = activeWindows[0];
    } else {
      targetWindow = inventoryWindows[0];
      targetWindow.focus();
    }
    targetWindow.navigate(targetUri);
  } else {
    self.clients.openWindow(targetUri);
  }
}
<|endoftext|>


<commit_before>Ep.VERSION = "0.1.3";
<commit_msg>Register EPF version with Ember.<commit_after>Ep.VERSION = "0.1.3";
Ember.libraries && Ember.libraries.register("EPF", Ep.VERSION);
<|endoftext|>


<commit_before>function(args) {
/*
is_app(true)
control_type("VB")
display_name("3d item")
description("This will return the 3d item control")
base_component_id("threedee_item_control")
load_once_from_file(true)
visibility("PRIVATE")
read_only(true)
properties(
    [
        {
            id:         "position",
            name:       "Position",
            type:       "String",
            default:    "-2.1 4 -10"
        }
        ,
        {
            id:         "boundingBox",
            name:       "Bounding Box",
            type:       "String",
            default:    "2 2 2"
        }
        ,
        {
            id:         "mass",
            name:       "Mass",
            type:       "Number",
            default:    5
        }
        ,
        {
            id:         "boxDepth",
            name:       "Box Depth",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "boxHeight",
            name:       "Box Height",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "boxWidth",
            name:       "Box Width",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "color",
            name:       "Color",
            type:       "String",
            default:    "#166678"
        }
        ,
        {
            id:         "rotation",
            name:       "Rotation",
            type:       "String",
            default:    "0 0 0"
        }
        ,
        {
            id:         "usePhysics",
            name:       "Physics?",
            type:       "Select",
            default:    false,
            values:     [
                            {display: "False",   value: false},
                            {display: "True",  value: true}
                        ]
        }
        ,
        {
            id:     "click_event",
            name:   "Clicked event",
            type:   "Event",
            help:       `
Help text for
                            click_event event

`
        }

    ]
)//properties
logo_url("/driver_icons/threedee_item.png")
*/

    Vue.component("threedee_item_control",{
        props: [  "meta", "args"  ,  "design_mode"  ,  "refresh"  ,  "name" ]
        ,
      template: `
                    <a-entity v-bind:id='name'
                              v-bind:ref='name'
                              v-bind:rotation='args.rotation'
                              v-bind:geometry='"primitive: box; depth: " + args.boxDepth + "; height: " + args.boxHeight + "; width: " + args.boxWidth + ";"'
                              v-bind:material='"color: " + args.color + "; side: double; "'
                              v-bind:physics-body='"mass: " + args.mass + "; boundingBox: " + args.boundingBox + "; shape: box;"'
                              v-bind:dynamic-body='args.usePhysics?true:false'
                              v-bind:refresh='refresh'
                              v-bind:position='args.position'>

              `

        ,

        mounted: function() {
            var mm = this
            registerComponent(this)
            var dd = document.getElementById(this.name)
            dd.addEventListener('click', function() {
                mm.event_callback()
            });
        }
        ,
        methods: {
            event_callback: function() {
                console.log("----- 3d text, event_callback: function() = " + this.name)
                //eval("(function(){" + this.args.click_event + "})")()

                this.$emit('send', {
                                                type:               "subcomponent_event",
                                                form_name:           this.meta.form,
                                                control_name:        this.meta.name,
                                                sub_type:           "click",
                                                code:                this.args.click_event
                                            })
            }
            ,
            moveRight: async function(amount) {
                this.args.position = "2 2 -5"

            }

        }
    })
}
<commit_msg>Physics can now be enabled on 3d blocks<commit_after>function(args) {
/*
is_app(true)
control_type("VB")
display_name("3d item")
description("This will return the 3d item control")
base_component_id("threedee_item_control")
load_once_from_file(true)
visibility("PRIVATE")
read_only(true)
properties(
    [
        {
            id:         "position",
            name:       "Position",
            type:       "String",
            default:    "-2.1 4 -10"
        }
        ,
        {
            id:         "boundingBox",
            name:       "Bounding Box",
            type:       "String",
            default:    "2 2 2"
        }
        ,
        {
            id:         "mass",
            name:       "Mass",
            type:       "Number",
            default:    5
        }
        ,
        {
            id:         "boxDepth",
            name:       "Box Depth",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "boxHeight",
            name:       "Box Height",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "boxWidth",
            name:       "Box Width",
            type:       "Number",
            default:    2
        }
        ,
        {
            id:         "color",
            name:       "Color",
            type:       "String",
            default:    "#166678"
        }
        ,
        {
            id:         "rotation",
            name:       "Rotation",
            type:       "String",
            default:    "0 0 0"
        }
        ,
        {
            id:         "usePhysics",
            name:       "Physics?",
            type:       "Select",
            default:    "false",
            values:     [
                            {display: "False",   value: "false"},
                            {display: "True",  value: "true"}
                        ]
        }
        ,
        {
            id:     "click_event",
            name:   "Clicked event",
            type:   "Event",
            help:       `
Help text for
                            click_event event

`
        }

    ]
)//properties
logo_url("/driver_icons/threedee_item.png")
*/

    Vue.component("threedee_item_control",{
        props: [  "meta", "args"  ,  "design_mode"  ,  "refresh"  ,  "name" ]
        ,
      template: `
                    <a-entity v-bind:id='name'
                              v-bind:ref='name'
                              v-bind:rotation='args.rotation'
                              v-bind:geometry='"primitive: box; depth: " + args.boxDepth + "; height: " + args.boxHeight + "; width: " + args.boxWidth + ";"'
                              v-bind:material='"color: " + args.color + "; side: double; "'
                              v-bind:physics-body='"mass: " + args.mass + "; boundingBox: " + args.boundingBox + "; shape: box;"'
                              v-bind:dynamic-body="(args.usePhysics == 'true')?true:false"
                              v-bind:refresh='refresh'
                              v-bind:position='args.position'>

              `

        ,

        mounted: function() {
            var mm = this
            registerComponent(this)
            var dd = document.getElementById(this.name)
            dd.addEventListener('click', function() {
                mm.event_callback()
            });
        }
        ,
        methods: {
            event_callback: function() {
                console.log("----- 3d text, event_callback: function() = " + this.name)
                //eval("(function(){" + this.args.click_event + "})")()

                this.$emit('send', {
                                                type:               "subcomponent_event",
                                                form_name:           this.meta.form,
                                                control_name:        this.meta.name,
                                                sub_type:           "click",
                                                code:                this.args.click_event
                                            })
            }
            ,
            moveRight: async function(amount) {
                this.args.position = "2 2 -5"

            }

        }
    })
}
<|endoftext|>


<commit_before>var _ = require('lodash');

module.exports = function (app) {
  app.post('/locale/changeLocale', function (req, res) {
    var supported = model.get('$locale.supported');
    if (!req.body.locale) return res.send(400, {error: 'locale missing'});
    if (!_.contains(supported, req.body.locale)) return res.send(400, {error: 'unsupported locale'});
    res.send();
  });

  return function (req, res, next) {
    next();
  }
};<commit_msg>formatting<commit_after>var _ = require('lodash');

module.exports = function (app) {
  app.post('/locale/changeLocale', function (req, res) {
    var supported = model.get('$locale.supported');
    var locale = req.body.locale;
    if (!locale) return res.send(400, {error: 'locale missing'});
    if (!_.contains(supported, locale)) return res.send(400, {error: 'unsupported locale'});
    res.send();
  });

  return function (req, res, next) {
    next();
  }
};<|endoftext|>


<commit_before>import { connect } from 'react-redux';

import Component from './section-partners-component';

const foundingPartners = [
  {
    img: '/assets/logos/bobolinkfundation.png',
    link: 'http://bobolinkfoundation.org',
    title: 'Bobo link Fundation'
  },
  {
    img: '/assets/logos/bluerasterhover.png',
    link: 'https://www.blueraster.com/',
    title: 'Blueraster'
  },
  {
    img: '/assets/logos/cartodbhover.png',
    link: 'https://carto.com/',
    title: 'Carto'
  },
  {
    img: '/assets/logos/centerforglobaldevelopmenthover.png',
    link: 'https://www.cgdev.org/',
    title: 'Center for Global Development'
  },
  {
    img: '/assets/logos/danidahover.png',
    link: 'http://um.dk/en/danida-en/',
    title: 'Danida'
  },
  {
    img: '/assets/logos/esrihover.png',
    link:
      'http://www.esri.com/landing-pages/fight-against-deforestation/global-forest-watch',
    title: 'ESRI'
  },
  {
    img: '/assets/logos/gefhover.png',
    link: 'http://www.thegef.org/',
    title: 'gef'
  },
  {
    img: '/assets/logos/globalforestwatchcanadahover.png',
    link: 'http://globalforestwatch.ca/',
    title: 'Global Forest Watch Canada'
  },
  {
    img: '/assets/logos/googlehover.png',
    link: 'https://earthengine.google.com/',
    title: 'Google'
  },
  {
    img: '/assets/logos/imazonhover.png',
    link: 'http://imazon.org.br/pagina-inicial-en?set_language=en&cl=en',
    title: 'Imazon'
  },
  {
    img: '/assets/logos/ministryofforeignaffairshover.png',
    link: 'https://www.government.nl/ministries/ministry-of-foreign-affairs',
    title: 'Ministry of Foreign Affairs'
  },
  {
    img: '/assets/logos/norwegianministrihover.png',
    link:
      'https://www.regjeringen.no/en/topics/climate-and-environment/climate/climate-and-forest-initiative/id2000712/',
    title: 'Norwegian Ministry'
  },
  {
    img: '/assets/logos/osfachover.png',
    link: 'https://osfac.net/index.php?lang=en',
    title: 'OSFA'
  },
  {
    img: '/assets/logos/scannexhover.png',
    link: 'http://www.scanex.ru/en/',
    title: 'Scannex'
  },
  {
    img: '/assets/logos/sidahover.png',
    link: 'http://www.sida.se/english/',
    title: 'SIDA'
  },
  {
    img: '/assets/logos/thejanegoodallinstitutehover.png',
    link: 'http://www.janegoodall.org/',
    title: 'The Jane Good all Institute'
  },
  {
    img: '/assets/logos/thetiliafundhover.png',
    link: 'http://www.tiliafund.org/',
    title: 'The Tila Fundation'
  },
  {
    img: '/assets/logos/tiposhover.png',
    link: 'http://www.transparentworld.ru/',
    title: 'TIPOS'
  },
  {
    img: '/assets/logos/unephover.png',
    link: 'http://www.unep.org/',
    title: 'UNEP'
  },
  {
    img: '/assets/logos/universityofmarylandhover.png',
    link: 'https://geog.umd.edu/',
    title: 'University of Maryland'
  },
  {
    img: '/assets/logos/ukaidhover.png',
    link:
      'https://www.gov.uk/government/organisations/department-for-international-development',
    title: 'UKAID'
  },
  {
    img: '/assets/logos/usaidhover.png',
    link: 'https://www.usaid.gov/',
    title: 'USAID'
  },
  {
    img: '/assets/logos/vizzualityhover.png',
    link: 'http://www.vizzuality.com/',
    title: 'Vizzuality'
  },
  {
    img: '/assets/logos/wrihover.png',
    link: 'http://www.wri.org/',
    title: 'World Resources Institute'
  }
];

const partnersCollaborators = [
  {
    img: '/assets/logos/afchover.png',
    link: 'http://www.afd.fr/home',
    title: 'Agence Française Développement'
  },
  {
    img: '/assets/logos/agrosatelitehover.png',
    link: 'http://agrosatelite.com.br/',
    title: 'agrosatelite'
  },
  {
    img: '/assets/logos/airbushover.png',
    link: 'http://www.airbus.com/',
    title: 'Airbus'
  },
  {
    img: '/assets/logos/astrodigitalhover.png',
    link: 'https://astrodigital.com/',
    title: 'Astro Digital'
  },
  {
    img: '/assets/logos/bnpbhover.png',
    link: 'https://bnpb.go.id/',
    title: 'Badan Nasional Penanggulangan Bencana'
  },
  {
    img: '/assets/logos/beihover.png',
    link:
      'http://www.cisl.cam.ac.uk/business-action/sustainable-finance/banking-environment-initiative',
    title: 'Banking Environment Initiative'
  },
  {
    img: '/assets/logos/cambridgehover.png',
    link: 'http://www.cisl.cam.ac.uk/',
    title: 'University of Cambridge'
  },
  {
    img: '/assets/logos/cargillhover.png',
    link: 'https://www.cargill.com/',
    title: 'Cargill'
  },
  {
    img: '/assets/logos/cgiarhover.png',
    link: 'http://foreststreesagroforestry.org/',
    title: 'Forest, Trees and Agroforestry'
  },
  {
    img: '/assets/logos/ciathover.png',
    link: 'http://ciat.cgiar.org/',
    title: 'CIAT'
  },
  {
    img: '/assets/logos/cluahover.png',
    link: 'http://www.climateandlandusealliance.org/',
    title: 'Climate and Land Use Alliance'
  },
  {
    img: '/assets/logos/conaforhover.png',
    link: 'http://www.conafor.gob.mx/',
    title: 'Conafor'
  },
  {
    img: '/assets/logos/conservationinternationalhover.png',
    link: 'http://www.conservation.org/Pages/default.aspx',
    title: 'Conservation International'
  },
  {
    img: '/assets/logos/digitalglobehover.png',
    link: 'https://www.digitalglobe.com/',
    title: 'DigitalGlobe'
  },
  {
    img: '/assets/logos/ejnhover.png',
    link: 'http://earthjournalism.net/',
    title: 'Earth Journalism Network'
  },
  {
    img: '/assets/logos/ewmihover.png',
    link: 'http://www.ewmi.org/',
    title: 'East West Management Institute'
  },
  {
    img: '/assets/logos/hakahover.png',
    link: 'http://www.haka.or.id/',
    title: 'Haka'
  },
  {
    img: '/assets/logos/icfhover.png',
    link: 'http://www.icf.gob.hn/',
    title: 'ICF'
  },
  {
    img: '/assets/logos/inabhover.png',
    link: 'http://www.inab.gob.gt/',
    title: 'inab'
  },
  {
    img: '/assets/logos/ioihover.png',
    link: 'http://europe.ioiloders.com/taking-responsibility',
    title: 'IOI Loders Croklaan'
  },
  {
    img: '/assets/logos/jjfasthover.png',
    link: 'http://www.eorc.jaxa.jp/jjfast/',
    title: 'JICA-JAXA Forest Early Warning System in the Tropics'
  },
  {
    img: '/assets/logos/lapighover.png',
    link: 'https://www.lapig.iesa.ufg.br/lapig/',
    title: 'LAPIG'
  },
  {
    img: '/assets/logos/minepathover.png',
    link: 'http://www.minepat.gov.cm/index.php/en/?lang=en',
    title: 'Minepat'
  },
  {
    img: '/assets/logos/ministierehover.png',
    link: '#',
    title: 'minfof'
  },
  {
    img: '/assets/logos/moiseshover.png',
    link: 'http://aidev.in/fmb/',
    title: 'Fundation Moises Bertoni'
  },
  {
    img: '/assets/logos/mongabayhover.png',
    link: 'https://www.mongabay.com/',
    title: 'Mongabay'
  },
  {
    img: '/assets/logos/muyissihover.png',
    link: '#',
    title: 'Muyissi'
  },
  {
    img: '/assets/logos/opendevcamhover.png',
    link: 'https://opendevelopmentcambodia.net/',
    title: 'Open Development Cambodia'
  },
  {
    img: '/assets/logos/orbitalhover.png',
    link: 'https://orbitalinsight.com/',
    title: 'Orbital Insight'
  },
  {
    img: '/assets/logos/osinforhover.png',
    link: 'http://www.osinfor.gob.pe/',
    title: 'Osinfor'
  },
  {
    img: '/assets/logos/rfukhover.png',
    link: 'http://www.rainforestfoundationuk.org/',
    title: 'Rainforest Foundation UK'
  },
  {
    img: '/assets/logos/raisghover.png',
    link: 'https://raisg.socioambiental.org/',
    title: 'RAISG'
  },
  {
    img: '/assets/logos/reddhover.png',
    link: 'http://www.redd-indonesia.org/',
    title: 'REDD Indonesia'
  },
  {
    img: '/assets/logos/rmhover.png',
    link: 'https://www.reforestamosmexico.org/',
    title: 'Refores@amos Mexico'
  },
  {
    img: '/assets/logos/resolvehover.png',
    link: 'http://www.resolv.org/site-BiodiversityWildlifeSolutions/',
    title: 'Resolve'
  },
  {
    img: '/assets/logos/rspohover.png',
    link: 'http://www.rspo.org/',
    title: 'RSPO'
  },
  {
    img: '/assets/logos/rtrshover.png',
    link: 'http://www.responsiblesoy.org/?lang=en',
    title: 'RTRS'
  },
  {
    img: '/assets/logos/unepwcmchover.png',
    link: 'http://www.unep-wcmc.org/',
    title: 'UNEP & WCMC'
  },
  {
    img: '/assets/logos/unileverhover.png',
    link: 'https://www.unilever.com/',
    title: 'Unilever'
  },
  {
    img: '/assets/logos/whrchover.png',
    link: 'http://whrc.org/',
    title: 'Woods Hole Research Center'
  }
];

const funders = [
  {
    img: '/assets/logos/cargillhover.png',
    link: 'https://www.cargill.com/',
    title: 'Cargill'
  },
  {
    img: '/assets/logos/gefhover.png',
    link: 'http://www.thegef.org/',
    title: 'gef'
  },
  {
    img: '/assets/logos/generationhover.png',
    link: 'https://www.genfound.org/',
    title: 'Generation Foundation'
  },
  {
    img: '/assets/logos/idbhover.png',
    link: 'http://www.iadb.org/en/inter-american-development-bank,2837.html',
    title: 'IDB'
  },
  {
    img: '/assets/logos/idbinvesthover.png',
    link: 'http://www.idbinvest.org/',
    title: 'IDB | Invest'
  },
  {
    img: '/assets/logos/macarthurhover.png',
    link: 'https://www.macfound.org/',
    title: 'MacArthur Foundation'
  },
  {
    img: '/assets/logos/norwegianministrihover.png',
    link:
      'https://www.regjeringen.no/en/topics/climate-and-environment/climate/climate-and-forest-initiative/id2000712/',
    title: 'Norwegian Ministry'
  },
  {
    img: '/assets/logos/ukaidhover.png',
    link:
      'https://www.gov.uk/government/organisations/department-for-international-development',
    title: 'UKAID'
  },
  {
    img: '/assets/logos/usaidhover.png',
    link: 'https://www.usaid.gov/',
    title: 'USAID'
  }
];

const mapStateToProps = () => ({
  foundingPartners,
  partnersCollaborators,
  funders
});

export default connect(mapStateToProps, null)(Component);
<commit_msg>fix reforestamos link in about<commit_after>import { connect } from 'react-redux';

import Component from './section-partners-component';

const foundingPartners = [
  {
    img: '/assets/logos/bobolinkfundation.png',
    link: 'http://bobolinkfoundation.org',
    title: 'Bobo link Fundation'
  },
  {
    img: '/assets/logos/bluerasterhover.png',
    link: 'https://www.blueraster.com/',
    title: 'Blueraster'
  },
  {
    img: '/assets/logos/cartodbhover.png',
    link: 'https://carto.com/',
    title: 'Carto'
  },
  {
    img: '/assets/logos/centerforglobaldevelopmenthover.png',
    link: 'https://www.cgdev.org/',
    title: 'Center for Global Development'
  },
  {
    img: '/assets/logos/danidahover.png',
    link: 'http://um.dk/en/danida-en/',
    title: 'Danida'
  },
  {
    img: '/assets/logos/esrihover.png',
    link:
      'http://www.esri.com/landing-pages/fight-against-deforestation/global-forest-watch',
    title: 'ESRI'
  },
  {
    img: '/assets/logos/gefhover.png',
    link: 'http://www.thegef.org/',
    title: 'gef'
  },
  {
    img: '/assets/logos/globalforestwatchcanadahover.png',
    link: 'http://globalforestwatch.ca/',
    title: 'Global Forest Watch Canada'
  },
  {
    img: '/assets/logos/googlehover.png',
    link: 'https://earthengine.google.com/',
    title: 'Google'
  },
  {
    img: '/assets/logos/imazonhover.png',
    link: 'http://imazon.org.br/pagina-inicial-en?set_language=en&cl=en',
    title: 'Imazon'
  },
  {
    img: '/assets/logos/ministryofforeignaffairshover.png',
    link: 'https://www.government.nl/ministries/ministry-of-foreign-affairs',
    title: 'Ministry of Foreign Affairs'
  },
  {
    img: '/assets/logos/norwegianministrihover.png',
    link:
      'https://www.regjeringen.no/en/topics/climate-and-environment/climate/climate-and-forest-initiative/id2000712/',
    title: 'Norwegian Ministry'
  },
  {
    img: '/assets/logos/osfachover.png',
    link: 'https://osfac.net/index.php?lang=en',
    title: 'OSFA'
  },
  {
    img: '/assets/logos/scannexhover.png',
    link: 'http://www.scanex.ru/en/',
    title: 'Scannex'
  },
  {
    img: '/assets/logos/sidahover.png',
    link: 'http://www.sida.se/english/',
    title: 'SIDA'
  },
  {
    img: '/assets/logos/thejanegoodallinstitutehover.png',
    link: 'http://www.janegoodall.org/',
    title: 'The Jane Good all Institute'
  },
  {
    img: '/assets/logos/thetiliafundhover.png',
    link: 'http://www.tiliafund.org/',
    title: 'The Tila Fundation'
  },
  {
    img: '/assets/logos/tiposhover.png',
    link: 'http://www.transparentworld.ru/',
    title: 'TIPOS'
  },
  {
    img: '/assets/logos/unephover.png',
    link: 'http://www.unep.org/',
    title: 'UNEP'
  },
  {
    img: '/assets/logos/universityofmarylandhover.png',
    link: 'https://geog.umd.edu/',
    title: 'University of Maryland'
  },
  {
    img: '/assets/logos/ukaidhover.png',
    link:
      'https://www.gov.uk/government/organisations/department-for-international-development',
    title: 'UKAID'
  },
  {
    img: '/assets/logos/usaidhover.png',
    link: 'https://www.usaid.gov/',
    title: 'USAID'
  },
  {
    img: '/assets/logos/vizzualityhover.png',
    link: 'http://www.vizzuality.com/',
    title: 'Vizzuality'
  },
  {
    img: '/assets/logos/wrihover.png',
    link: 'http://www.wri.org/',
    title: 'World Resources Institute'
  }
];

const partnersCollaborators = [
  {
    img: '/assets/logos/afchover.png',
    link: 'http://www.afd.fr/home',
    title: 'Agence Française Développement'
  },
  {
    img: '/assets/logos/agrosatelitehover.png',
    link: 'http://agrosatelite.com.br/',
    title: 'agrosatelite'
  },
  {
    img: '/assets/logos/airbushover.png',
    link: 'http://www.airbus.com/',
    title: 'Airbus'
  },
  {
    img: '/assets/logos/astrodigitalhover.png',
    link: 'https://astrodigital.com/',
    title: 'Astro Digital'
  },
  {
    img: '/assets/logos/bnpbhover.png',
    link: 'https://bnpb.go.id/',
    title: 'Badan Nasional Penanggulangan Bencana'
  },
  {
    img: '/assets/logos/beihover.png',
    link:
      'http://www.cisl.cam.ac.uk/business-action/sustainable-finance/banking-environment-initiative',
    title: 'Banking Environment Initiative'
  },
  {
    img: '/assets/logos/cambridgehover.png',
    link: 'http://www.cisl.cam.ac.uk/',
    title: 'University of Cambridge'
  },
  {
    img: '/assets/logos/cargillhover.png',
    link: 'https://www.cargill.com/',
    title: 'Cargill'
  },
  {
    img: '/assets/logos/cgiarhover.png',
    link: 'http://foreststreesagroforestry.org/',
    title: 'Forest, Trees and Agroforestry'
  },
  {
    img: '/assets/logos/ciathover.png',
    link: 'http://ciat.cgiar.org/',
    title: 'CIAT'
  },
  {
    img: '/assets/logos/cluahover.png',
    link: 'http://www.climateandlandusealliance.org/',
    title: 'Climate and Land Use Alliance'
  },
  {
    img: '/assets/logos/conaforhover.png',
    link: 'http://www.conafor.gob.mx/',
    title: 'Conafor'
  },
  {
    img: '/assets/logos/conservationinternationalhover.png',
    link: 'http://www.conservation.org/Pages/default.aspx',
    title: 'Conservation International'
  },
  {
    img: '/assets/logos/digitalglobehover.png',
    link: 'https://www.digitalglobe.com/',
    title: 'DigitalGlobe'
  },
  {
    img: '/assets/logos/ejnhover.png',
    link: 'http://earthjournalism.net/',
    title: 'Earth Journalism Network'
  },
  {
    img: '/assets/logos/ewmihover.png',
    link: 'http://www.ewmi.org/',
    title: 'East West Management Institute'
  },
  {
    img: '/assets/logos/hakahover.png',
    link: 'http://www.haka.or.id/',
    title: 'Haka'
  },
  {
    img: '/assets/logos/icfhover.png',
    link: 'http://www.icf.gob.hn/',
    title: 'ICF'
  },
  {
    img: '/assets/logos/inabhover.png',
    link: 'http://www.inab.gob.gt/',
    title: 'inab'
  },
  {
    img: '/assets/logos/ioihover.png',
    link: 'http://europe.ioiloders.com/taking-responsibility',
    title: 'IOI Loders Croklaan'
  },
  {
    img: '/assets/logos/jjfasthover.png',
    link: 'http://www.eorc.jaxa.jp/jjfast/',
    title: 'JICA-JAXA Forest Early Warning System in the Tropics'
  },
  {
    img: '/assets/logos/lapighover.png',
    link: 'https://www.lapig.iesa.ufg.br/lapig/',
    title: 'LAPIG'
  },
  {
    img: '/assets/logos/minepathover.png',
    link: 'http://www.minepat.gov.cm/index.php/en/?lang=en',
    title: 'Minepat'
  },
  {
    img: '/assets/logos/ministierehover.png',
    link: '#',
    title: 'minfof'
  },
  {
    img: '/assets/logos/moiseshover.png',
    link: 'http://aidev.in/fmb/',
    title: 'Fundation Moises Bertoni'
  },
  {
    img: '/assets/logos/mongabayhover.png',
    link: 'https://www.mongabay.com/',
    title: 'Mongabay'
  },
  {
    img: '/assets/logos/muyissihover.png',
    link: '#',
    title: 'Muyissi'
  },
  {
    img: '/assets/logos/opendevcamhover.png',
    link: 'https://opendevelopmentcambodia.net/',
    title: 'Open Development Cambodia'
  },
  {
    img: '/assets/logos/orbitalhover.png',
    link: 'https://orbitalinsight.com/',
    title: 'Orbital Insight'
  },
  {
    img: '/assets/logos/osinforhover.png',
    link: 'http://www.osinfor.gob.pe/',
    title: 'Osinfor'
  },
  {
    img: '/assets/logos/rfukhover.png',
    link: 'http://www.rainforestfoundationuk.org/',
    title: 'Rainforest Foundation UK'
  },
  {
    img: '/assets/logos/raisghover.png',
    link: 'https://raisg.socioambiental.org/',
    title: 'RAISG'
  },
  {
    img: '/assets/logos/reddhover.png',
    link: 'http://www.redd-indonesia.org/',
    title: 'REDD Indonesia'
  },
  {
    img: '/assets/logos/rmhover.png',
    link: 'http://www.reforestamosmexico.org/',
    title: 'Refores@amos Mexico'
  },
  {
    img: '/assets/logos/resolvehover.png',
    link: 'http://www.resolv.org/site-BiodiversityWildlifeSolutions/',
    title: 'Resolve'
  },
  {
    img: '/assets/logos/rspohover.png',
    link: 'http://www.rspo.org/',
    title: 'RSPO'
  },
  {
    img: '/assets/logos/rtrshover.png',
    link: 'http://www.responsiblesoy.org/?lang=en',
    title: 'RTRS'
  },
  {
    img: '/assets/logos/unepwcmchover.png',
    link: 'http://www.unep-wcmc.org/',
    title: 'UNEP & WCMC'
  },
  {
    img: '/assets/logos/unileverhover.png',
    link: 'https://www.unilever.com/',
    title: 'Unilever'
  },
  {
    img: '/assets/logos/whrchover.png',
    link: 'http://whrc.org/',
    title: 'Woods Hole Research Center'
  }
];

const funders = [
  {
    img: '/assets/logos/cargillhover.png',
    link: 'https://www.cargill.com/',
    title: 'Cargill'
  },
  {
    img: '/assets/logos/gefhover.png',
    link: 'http://www.thegef.org/',
    title: 'gef'
  },
  {
    img: '/assets/logos/generationhover.png',
    link: 'https://www.genfound.org/',
    title: 'Generation Foundation'
  },
  {
    img: '/assets/logos/idbhover.png',
    link: 'http://www.iadb.org/en/inter-american-development-bank,2837.html',
    title: 'IDB'
  },
  {
    img: '/assets/logos/idbinvesthover.png',
    link: 'http://www.idbinvest.org/',
    title: 'IDB | Invest'
  },
  {
    img: '/assets/logos/macarthurhover.png',
    link: 'https://www.macfound.org/',
    title: 'MacArthur Foundation'
  },
  {
    img: '/assets/logos/norwegianministrihover.png',
    link:
      'https://www.regjeringen.no/en/topics/climate-and-environment/climate/climate-and-forest-initiative/id2000712/',
    title: 'Norwegian Ministry'
  },
  {
    img: '/assets/logos/ukaidhover.png',
    link:
      'https://www.gov.uk/government/organisations/department-for-international-development',
    title: 'UKAID'
  },
  {
    img: '/assets/logos/usaidhover.png',
    link: 'https://www.usaid.gov/',
    title: 'USAID'
  }
];

const mapStateToProps = () => ({
  foundingPartners,
  partnersCollaborators,
  funders
});

export default connect(mapStateToProps, null)(Component);
<|endoftext|>


<commit_before>if (typeof JSDOC == "undefined") JSDOC = {};

/**
	@class Search a {@link JSDOC.TextStream} for language tokens.
*/
JSDOC.TokenReader = function() {
	this.keepDocs = true;
	this.keepWhite = false;
	this.keepComments = false;
}

/**
	@type {JSDOC.Token[]}
 */
JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) {
	var tokens = [];
	/**@ignore*/ tokens.last    = function() { return tokens[tokens.length-1]; }
	/**@ignore*/ tokens.lastSym = function() {
		for (var i = tokens.length-1; i >= 0; i--) {
			if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i];
		}
	}

	while (!stream.look().eof) {
		if (this.read_mlcomment(stream, tokens)) continue;
		if (this.read_slcomment(stream, tokens)) continue;
		if (this.read_dbquote(stream, tokens))   continue;
		if (this.read_snquote(stream, tokens))   continue;
		if (this.read_regx(stream, tokens))      continue;
		if (this.read_numb(stream, tokens))      continue;
		if (this.read_punc(stream, tokens))      continue;
		if (this.read_newline(stream, tokens))   continue;
		if (this.read_space(stream, tokens))     continue;
		if (this.read_word(stream, tokens))      continue;

		// if execution reaches here then an error has happened
		tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN"));
	}
	return tokens;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";
	while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		var name;
		if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name));
		else tokens.push(new JSDOC.Token(found, "NAME", "NAME"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";
	var name;
	while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found)));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (this.collapseWhite) found = " ";
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (this.collapseWhite) found = "\n";
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "/" && stream.look(1) == "*") {
		var found = stream.next(2);

		while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
			found += stream.next();
		}

		// to start doclet we allow /** or /*** but not /**/ or /****
		if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC"));
		else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM"));
		return true;
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found;
	if (
		(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
		||
		(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
	) {

		while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) {
			found += stream.next();
		}

		if (this.keepComments) {
			tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM"));
		}
		return true;
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "\"") {
		// find terminator
		var string = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") {
				if (JSDOC.Lang.isNewline(stream.look(1))) {
					do {
						stream.next();
					} while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look()));
					string += "\\\n";
				}
				else {
					string += stream.next(2);
				}
			}
			else if (stream.look() == "\"") {
				string += stream.next();
				tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE"));
				return true;
			}
			else {
				string += stream.next();
			}
		}
	}
	return false; // error! unterminated string
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "'") {
		// find terminator
		var string = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") { // escape sequence
				string += stream.next(2);
			}
			else if (stream.look() == "'") {
				string += stream.next();
				tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE"));
				return true;
			}
			else {
				string += stream.next();
			}
		}
	}
	return false; // error! unterminated string
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() === "0" && stream.look(1) == "x") {
		return this.read_hex(stream, tokens);
	}

	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL"));
		else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL"));
		return true;
	}
}
/*t:
	requires("../lib/JSDOC/TextStream.js");
	requires("../lib/JSDOC/Token.js");
	requires("../lib/JSDOC/Lang.js");

	plan(3, "testing JSDOC.TokenReader.prototype.read_numb");

	//// setup
	var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}";
	var tr = new JSDOC.TokenReader();
	var tokens = tr.tokenize(new JSDOC.TextStream(src));

	var hexToken, octToken, decToken;
	for (var i = 0; i < tokens.length; i++) {
		if (tokens[i].name == "HEX_DEC") hexToken = tokens[i];
		if (tokens[i].name == "OCTAL") octToken = tokens[i];
		if (tokens[i].name == "DECIMAL") decToken = tokens[i];
	}
	////

	is(decToken.data, "8.0", "decimal number is found in source.");
	is(hexToken.data, "0x20", "hexdec number is found in source (issue #99).");
	is(octToken.data, "0777", "octal number is found in source.");
*/

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = stream.next(2);

	while (!stream.look().eof) {
		if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done
			tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC"));
			return true;
		}
		else {
			found += stream.next();
		}
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) {
	var last;
	if (
		stream.look() == "/"
		&&
		(

			(
				!(last = tokens.lastSym()) // there is no last, the regex is the first symbol
				||
				(
					   !last.is("NUMB")
					&& !last.is("NAME")
					&& !last.is("RIGHT_PAREN")
					&& !last.is("RIGHT_BRACKET")
				)
			)
		)
	) {
		var regex = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") { // escape sequence
				regex += stream.next(2);
			}
			else if (stream.look() == "/") {
				regex += stream.next();

				while (/[gmi]/.test(stream.look())) {
					regex += stream.next();
				}

				tokens.push(new JSDOC.Token(regex, "REGX", "REGX"));
				return true;
			}
			else {
				regex += stream.next();
			}
		}
		// error: unterminated regex
	}
	return false;
}
<commit_msg>jsdoc: remove comments that Rhino bugs out on.<commit_after>if (typeof JSDOC == "undefined") JSDOC = {};

/**
	@class Search a {@link JSDOC.TextStream} for language tokens.
*/
JSDOC.TokenReader = function() {
	this.keepDocs = true;
	this.keepWhite = false;
	this.keepComments = false;
}

/**
	@type {JSDOC.Token[]}
 */
JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) {
	var tokens = [];
	tokens.last    = function() { return tokens[tokens.length-1]; }
	tokens.lastSym = function() {
		for (var i = tokens.length-1; i >= 0; i--) {
			if (!(tokens[i].is("WHIT") || tokens[i].is("COMM"))) return tokens[i];
		}
	}

	while (!stream.look().eof) {
		if (this.read_mlcomment(stream, tokens)) continue;
		if (this.read_slcomment(stream, tokens)) continue;
		if (this.read_dbquote(stream, tokens))   continue;
		if (this.read_snquote(stream, tokens))   continue;
		if (this.read_regx(stream, tokens))      continue;
		if (this.read_numb(stream, tokens))      continue;
		if (this.read_punc(stream, tokens))      continue;
		if (this.read_newline(stream, tokens))   continue;
		if (this.read_space(stream, tokens))     continue;
		if (this.read_word(stream, tokens))      continue;

		// if execution reaches here then an error has happened
		tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN"));
	}
	return tokens;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";
	while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		var name;
		if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name));
		else tokens.push(new JSDOC.Token(found, "NAME", "NAME"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";
	var name;
	while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found)));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (this.collapseWhite) found = " ";
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) {
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (this.collapseWhite) found = "\n";
		if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE"));
		return true;
	}
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "/" && stream.look(1) == "*") {
		var found = stream.next(2);

		while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
			found += stream.next();
		}

		// to start doclet we allow /** or /*** but not /**/ or /****
		if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC"));
		else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM"));
		return true;
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found;
	if (
		(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
		||
		(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
	) {

		while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) {
			found += stream.next();
		}

		if (this.keepComments) {
			tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM"));
		}
		return true;
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "\"") {
		// find terminator
		var string = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") {
				if (JSDOC.Lang.isNewline(stream.look(1))) {
					do {
						stream.next();
					} while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look()));
					string += "\\\n";
				}
				else {
					string += stream.next(2);
				}
			}
			else if (stream.look() == "\"") {
				string += stream.next();
				tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE"));
				return true;
			}
			else {
				string += stream.next();
			}
		}
	}
	return false; // error! unterminated string
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() == "'") {
		// find terminator
		var string = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") { // escape sequence
				string += stream.next(2);
			}
			else if (stream.look() == "'") {
				string += stream.next();
				tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE"));
				return true;
			}
			else {
				string += stream.next();
			}
		}
	}
	return false; // error! unterminated string
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) {
	if (stream.look() === "0" && stream.look(1) == "x") {
		return this.read_hex(stream, tokens);
	}

	var found = "";

	while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){
		found += stream.next();
	}

	if (found === "") {
		return false;
	}
	else {
		if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL"));
		else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL"));
		return true;
	}
}
/*t:
	requires("../lib/JSDOC/TextStream.js");
	requires("../lib/JSDOC/Token.js");
	requires("../lib/JSDOC/Lang.js");

	plan(3, "testing JSDOC.TokenReader.prototype.read_numb");

	//// setup
	var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}";
	var tr = new JSDOC.TokenReader();
	var tokens = tr.tokenize(new JSDOC.TextStream(src));

	var hexToken, octToken, decToken;
	for (var i = 0; i < tokens.length; i++) {
		if (tokens[i].name == "HEX_DEC") hexToken = tokens[i];
		if (tokens[i].name == "OCTAL") octToken = tokens[i];
		if (tokens[i].name == "DECIMAL") decToken = tokens[i];
	}
	////

	is(decToken.data, "8.0", "decimal number is found in source.");
	is(hexToken.data, "0x20", "hexdec number is found in source (issue #99).");
	is(octToken.data, "0777", "octal number is found in source.");
*/

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) {
	var found = stream.next(2);

	while (!stream.look().eof) {
		if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done
			tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC"));
			return true;
		}
		else {
			found += stream.next();
		}
	}
	return false;
}

/**
	@returns {Boolean} Was the token found?
 */
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) {
	var last;
	if (
		stream.look() == "/"
		&&
		(

			(
				!(last = tokens.lastSym()) // there is no last, the regex is the first symbol
				||
				(
					   !last.is("NUMB")
					&& !last.is("NAME")
					&& !last.is("RIGHT_PAREN")
					&& !last.is("RIGHT_BRACKET")
				)
			)
		)
	) {
		var regex = stream.next();

		while (!stream.look().eof) {
			if (stream.look() == "\\") { // escape sequence
				regex += stream.next(2);
			}
			else if (stream.look() == "/") {
				regex += stream.next();

				while (/[gmi]/.test(stream.look())) {
					regex += stream.next();
				}

				tokens.push(new JSDOC.Token(regex, "REGX", "REGX"));
				return true;
			}
			else {
				regex += stream.next();
			}
		}
		// error: unterminated regex
	}
	return false;
}
<|endoftext|>


<commit_before>#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const Listr = require('listr');
const execa = require('execa');
const chalk = require('chalk');
const del = require('del');
const UpdaterRenderer = require('listr-update-renderer');
const moment = require('moment');
const argv = require('minimist')(process.argv.slice(2), {
    string: ['appMode'],
    boolean: ['lint', 'i18n'],
    default: {
        lint: true,
        fromCi: false,
        i18n: true,
        localize: false,
        appMode: 'bundle',
        remote: false,
        forceFetch: false,
        silentMessage: false
    }
});

// Compat mode WebClient
const ENV_FILE = fs.existsSync('.env') ? '.env' : 'env/.env';
require('dotenv').config({ path: ENV_FILE });

const { debug, success, error, about, warn } = require('./lib/helpers/log')('proton-bundler');
const coucou = require('./lib/helpers/coucou');
const { bash, script } = require('./lib/helpers/cli');
const {
    customBundler: { tasks: customTasks, config: customConfig },
    getCustomHooks
} = require('./lib/custom');
const { pull, push, getConfig, logCommits, generateChangelog } = require('./lib/git');
const buildRemote = require('./lib/buildRemote');

const PKG = require(path.join(process.cwd(), 'package.json'));

const getTasks = (branch, { isCI, flowType = 'single', forceI18n, appMode, runI18n, isRemoteBuild }) => {
    const { EXTERNAL_FILES = ['.htaccess'] } = customConfig;
    const { hookPreTasks, hookPostTasks, hookPostTaskClone, hookPostTaskBuild, customConfigSetup } = getCustomHooks(
        customTasks({
            branch,
            isCI,
            flowType,
            appMode,
            forceI18n,
            runI18n,
            isRemoteBuild
        })
    );

    const configTasks = customConfigSetup.length
        ? customConfigSetup
        : [
              {
                  title: 'Setup app config',
                  enabled: () => !isCI,
                  task() {
                      return bash('npx proton-pack', process.argv.slice(2));
                  }
              }
          ];

    const list = [
        ...hookPreTasks,
        {
            title: 'Save dependencies if we need',
            enabled: () => !isRemoteBuild && !isCI && /dev|beta|alpha/.test(branch),
            task() {
                return script('updatePackageLock.sh', [argv['default-branch']]);
            }
        },
        {
            title: 'Clear previous dist',
            async task() {
                await del(['dist', 'distCurrent', 'distback'], { dryRun: false });
                isCI && execa.shell('mkdir dist');
            }
        },
        {
            title: 'Lint sources',
            enabled: () => argv.lint !== false && !isRemoteBuild,
            task: () => execa('npm', ['run', 'lint'])
        },
        ...configTasks,
        {
            title: 'Extract git env for the bundle',
            enabled: () => !isCI,
            async task(ctx) {
                const { commit, branch, tag } = await getConfig();
                ctx.originCommit = commit;
                ctx.originBranch = branch;
                ctx.tag = tag;
            }
        },
        {
            title: `Pull dist branch ${branch}`,
            enabled: () => !isCI,
            task: () => pull(branch, argv.forceFetch, argv.fromCi)
        },
        ...hookPostTaskClone,
        {
            title: 'Copy some files',
            task() {
                const rule = EXTERNAL_FILES.length > 1 ? `{${EXTERNAL_FILES.join(',')}}` : EXTERNAL_FILES.join(',');
                return bash(`cp src/${rule} dist/`);
            }
        },
        {
            title: 'Upgrade translations inside the app',
            enabled: () => forceI18n || (runI18n && !isCI && /prod|beta/.test(branch)),
            task() {
                return execa('npm', ['run', 'i18n:getlatest']);
            }
        },
        {
            title: 'Build the application',
            task() {
                const args = process.argv.slice(2);
                if (appMode === 'standalone') {
                    return execa('npm', ['run', 'build:standalone', '--', ...args]);
                }

                return execa('npm', ['run', 'build', '--', ...args]);
            }
        },
        ...hookPostTaskBuild,
        {
            title: `Push dist to ${branch}`,
            enabled: () => !isCI,
            task: (ctx) => push(branch, ctx)
        },
        {
            title: 'Update crowdin with latest translations',
            enabled: () => runI18n && !isCI && /prod|beta/.test(branch),
            task() {
                return execa('npm', ['run', 'i18n:upgrade']);
            }
        },
        ...hookPostTasks,
        {
            title: 'Inform us about new translations available',
            enabled: () => runI18n && !isCI && /prod|beta/.test(branch),
            task() {
                const [, type] = branch.match(/deploy-(\w+)/) || [];
                return execa('npx', ['proton-i18n', 'coucou', type]);
            }
        }
    ];
    return list;
};

/**
 * Get the API dest when we deploy.
 * You can use the custom config from proton.bundler.js to get it
 * @return {Promise<String>}
 */
async function getAPIUrl() {
    if (customConfig.apiUrl) {
        return customConfig.apiUrl;
    }

    const args = process.argv.slice(2);
    const { stdout } = await bash('npx proton-pack print-config', args);
    debug(stdout, 'print-config output');
    const [, url] = stdout.match(/apiUrl": "(.+)"(,*?)/);
    return url;
}

async function main() {
    /*
        If we build from the remote repository we need to:
            - clone the repository inside /tmp
            - install dependencies
            - run the deploy command again from this directory
        So let's put an end to the current deploy.
     */
    if (argv.remote) {
        await buildRemote(PKG);
        const args = process.argv.slice(2).filter((key) => !/--remote/.test(key));
        return script('builder.sh', [PKG.name, ...args], 'inherit'); // inherit for the colors ;)
    }

    // Custom local deploy for the CI
    const isCI = process.env.NODE_ENV_DIST === 'ci';
    const branch = argv.branch;
    const flowType = argv.flow;
    const runI18n = argv.i18n;
    const forceI18n = argv.localize;
    const appMode = argv.appMode;
    const isRemoteBuild = argv.source === 'remote';

    debug({ customConfig, argv }, 'configuration deploy');

    if (!branch && !isCI) {
        throw new Error('You must define a branch name. --branch=XXX');
    }

    const apiUrl = await getAPIUrl();

    process.env.NODE_ENV_BRANCH = branch;
    process.env.NODE_ENV_API = apiUrl;

    about({
        ...(!isCI && { branch }),
        apiUrl,
        appMode,
        isRemoteBuild,
        SENTRY: process.env.NODE_ENV_SENTRY
    });

    const start = moment(Date.now());
    const listTasks = getTasks(branch, { isCI, flowType, forceI18n, appMode, runI18n, isRemoteBuild });
    const tasks = new Listr(listTasks, {
        renderer: UpdaterRenderer,
        collapse: false
    });

    await tasks.run();

    const now = moment(Date.now());
    const total = now.diff(start, 'seconds');
    const time = total > 60 ? moment.utc(total * 1000).format('mm:ss') : `${total}s`;

    !isCI && success('App deployment done', { time });
    isCI && success(`Build CI app to the directory: ${chalk.bold('dist')}`, { time });

    if (!isCI && !argv.silentMessage) {
        return logCommits(branch, flowType).then((data) => {
            if (/deploy-(beta|prod|old|tor|dev)/.test(branch)) {
                const [, env] = branch.match(/deploy-(beta|prod|old|tor|dev)/);
                coucou.send(data, { env, flowType }, PKG);
            }
        });
    }
}

if (argv._.includes('hosts')) {
    return script('createNewDeployBranch.sh', process.argv.slice(3)).then(({ stdout }) => console.log(stdout));
}

if (argv._.includes('log-commits')) {
    const { branch, flow: flowType, custom } = argv;
    debug(argv, 'arguments');
    return logCommits(branch, flowType).then((data) => {
        if (/deploy-(beta|prod|old|tor|dev)/.test(branch)) {
            const [, env] = branch.match(/deploy-(beta|prod|old|tor|dev)/);
            coucou.send(data, { env, flowType, custom }, PKG);
        }
    });
}

if (argv._.includes('changelog')) {
    const { branch } = argv;
    const url = argv.url || (PKG.bugs || {}).url;
    debug({ argv }, 'arguments');

    if (!['dev', process.env.QA_BRANCH].includes(branch)) {
        return warn(`No changelog available for the branch ${branch}`); // not available
    }

    if (!url) {
        return warn('No URL found for the issues');
    }

    return generateChangelog(branch, url).then((data) => {
        if (data) {
            coucou.send(data, { env: branch, mode: 'changelog' }, PKG);
        }
    });
}

main().catch(error);
<commit_msg>Fix import bash<commit_after>#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const Listr = require('listr');
const execa = require('execa');
const chalk = require('chalk');
const del = require('del');
const UpdaterRenderer = require('listr-update-renderer');
const moment = require('moment');
const argv = require('minimist')(process.argv.slice(2), {
    string: ['appMode'],
    boolean: ['lint', 'i18n'],
    default: {
        lint: true,
        fromCi: false,
        i18n: true,
        localize: false,
        appMode: 'bundle',
        remote: false,
        forceFetch: false,
        silentMessage: false
    }
});

// Compat mode WebClient
const ENV_FILE = fs.existsSync('.env') ? '.env' : 'env/.env';
require('dotenv').config({ path: ENV_FILE });

const { debug, success, error, about, warn } = require('./lib/helpers/log')('proton-bundler');
const coucou = require('./lib/helpers/coucou');
const { bash, script } = require('./lib/helpers/cli');
const {
    customBundler: { tasks: customTasks, config: customConfig },
    getCustomHooks
} = require('./lib/custom');
const { pull, push, getConfig, logCommits, generateChangelog } = require('./lib/git');
const buildRemote = require('./lib/buildRemote');

const PKG = require(path.join(process.cwd(), 'package.json'));

const getTasks = (branch, { isCI, flowType = 'single', forceI18n, appMode, runI18n, isRemoteBuild }) => {
    const { EXTERNAL_FILES = ['.htaccess'] } = customConfig;
    const { hookPreTasks, hookPostTasks, hookPostTaskClone, hookPostTaskBuild, customConfigSetup } = getCustomHooks(
        customTasks({
            branch,
            isCI,
            flowType,
            appMode,
            forceI18n,
            runI18n,
            isRemoteBuild
        })
    );

    const configTasks = customConfigSetup.length
        ? customConfigSetup
        : [
              {
                  title: 'Setup app config',
                  enabled: () => !isCI,
                  task() {
                      return bash('npx proton-pack', process.argv.slice(2));
                  }
              }
          ];

    const list = [
        ...hookPreTasks,
        {
            title: 'Save dependencies if we need',
            enabled: () => !isRemoteBuild && !isCI && /dev|beta|alpha/.test(branch),
            task() {
                return script('updatePackageLock.sh', [argv['default-branch']]);
            }
        },
        {
            title: 'Clear previous dist',
            async task() {
                await del(['dist', 'distCurrent', 'distback'], { dryRun: false });
                isCI && execa('mkdir dist');
            }
        },
        {
            title: 'Lint sources',
            enabled: () => argv.lint !== false && !isRemoteBuild,
            task: () => execa('npm', ['run', 'lint'])
        },
        ...configTasks,
        {
            title: 'Extract git env for the bundle',
            enabled: () => !isCI,
            async task(ctx) {
                const { commit, branch, tag } = await getConfig();
                ctx.originCommit = commit;
                ctx.originBranch = branch;
                ctx.tag = tag;
            }
        },
        {
            title: `Pull dist branch ${branch}`,
            enabled: () => !isCI,
            task: () => pull(branch, argv.forceFetch, argv.fromCi)
        },
        ...hookPostTaskClone,
        {
            title: 'Copy some files',
            task() {
                const rule = EXTERNAL_FILES.length > 1 ? `{${EXTERNAL_FILES.join(',')}}` : EXTERNAL_FILES.join(',');
                return bash(`cp src/${rule} dist/`);
            }
        },
        {
            title: 'Upgrade translations inside the app',
            enabled: () => forceI18n || (runI18n && !isCI && /prod|beta/.test(branch)),
            task() {
                return execa('npm', ['run', 'i18n:getlatest']);
            }
        },
        {
            title: 'Build the application',
            task() {
                const args = process.argv.slice(2);
                if (appMode === 'standalone') {
                    return execa('npm', ['run', 'build:standalone', '--', ...args]);
                }

                return execa('npm', ['run', 'build', '--', ...args]);
            }
        },
        ...hookPostTaskBuild,
        {
            title: `Push dist to ${branch}`,
            enabled: () => !isCI,
            task: (ctx) => push(branch, ctx)
        },
        {
            title: 'Update crowdin with latest translations',
            enabled: () => runI18n && !isCI && /prod|beta/.test(branch),
            task() {
                return execa('npm', ['run', 'i18n:upgrade']);
            }
        },
        ...hookPostTasks,
        {
            title: 'Inform us about new translations available',
            enabled: () => runI18n && !isCI && /prod|beta/.test(branch),
            task() {
                const [, type] = branch.match(/deploy-(\w+)/) || [];
                return execa('npx', ['proton-i18n', 'coucou', type]);
            }
        }
    ];
    return list;
};

/**
 * Get the API dest when we deploy.
 * You can use the custom config from proton.bundler.js to get it
 * @return {Promise<String>}
 */
async function getAPIUrl() {
    if (customConfig.apiUrl) {
        return customConfig.apiUrl;
    }

    const args = process.argv.slice(2);
    const { stdout } = await bash('npx proton-pack print-config', args);
    debug(stdout, 'print-config output');
    const [, url] = stdout.match(/apiUrl": "(.+)"(,*?)/);
    return url;
}

async function main() {
    /*
        If we build from the remote repository we need to:
            - clone the repository inside /tmp
            - install dependencies
            - run the deploy command again from this directory
        So let's put an end to the current deploy.
     */
    if (argv.remote) {
        await buildRemote(PKG);
        const args = process.argv.slice(2).filter((key) => !/--remote/.test(key));
        return script('builder.sh', [PKG.name, ...args], 'inherit'); // inherit for the colors ;)
    }

    // Custom local deploy for the CI
    const isCI = process.env.NODE_ENV_DIST === 'ci';
    const branch = argv.branch;
    const flowType = argv.flow;
    const runI18n = argv.i18n;
    const forceI18n = argv.localize;
    const appMode = argv.appMode;
    const isRemoteBuild = argv.source === 'remote';

    debug({ customConfig, argv }, 'configuration deploy');

    if (!branch && !isCI) {
        throw new Error('You must define a branch name. --branch=XXX');
    }

    const apiUrl = await getAPIUrl();

    process.env.NODE_ENV_BRANCH = branch;
    process.env.NODE_ENV_API = apiUrl;

    about({
        ...(!isCI && { branch }),
        apiUrl,
        appMode,
        isRemoteBuild,
        SENTRY: process.env.NODE_ENV_SENTRY
    });

    const start = moment(Date.now());
    const listTasks = getTasks(branch, { isCI, flowType, forceI18n, appMode, runI18n, isRemoteBuild });
    const tasks = new Listr(listTasks, {
        renderer: UpdaterRenderer,
        collapse: false
    });

    await tasks.run();

    const now = moment(Date.now());
    const total = now.diff(start, 'seconds');
    const time = total > 60 ? moment.utc(total * 1000).format('mm:ss') : `${total}s`;

    !isCI && success('App deployment done', { time });
    isCI && success(`Build CI app to the directory: ${chalk.bold('dist')}`, { time });

    if (!isCI && !argv.silentMessage) {
        return logCommits(branch, flowType).then((data) => {
            if (/deploy-(beta|prod|old|tor|dev)/.test(branch)) {
                const [, env] = branch.match(/deploy-(beta|prod|old|tor|dev)/);
                coucou.send(data, { env, flowType }, PKG);
            }
        });
    }
}

if (argv._.includes('hosts')) {
    return script('createNewDeployBranch.sh', process.argv.slice(3)).then(({ stdout }) => console.log(stdout));
}

if (argv._.includes('log-commits')) {
    const { branch, flow: flowType, custom } = argv;
    debug(argv, 'arguments');
    return logCommits(branch, flowType).then((data) => {
        if (/deploy-(beta|prod|old|tor|dev)/.test(branch)) {
            const [, env] = branch.match(/deploy-(beta|prod|old|tor|dev)/);
            coucou.send(data, { env, flowType, custom }, PKG);
        }
    });
}

if (argv._.includes('changelog')) {
    const { branch } = argv;
    const url = argv.url || (PKG.bugs || {}).url;
    debug({ argv }, 'arguments');

    if (!['dev', process.env.QA_BRANCH].includes(branch)) {
        return warn(`No changelog available for the branch ${branch}`); // not available
    }

    if (!url) {
        return warn('No URL found for the issues');
    }

    return generateChangelog(branch, url).then((data) => {
        if (data) {
            coucou.send(data, { env: branch, mode: 'changelog' }, PKG);
        }
    });
}

main().catch(error);
<|endoftext|>


<commit_before>/**
 * Item View
 *
 * This is the item view, it is rendered when users visit a page of a specific
 * item. This mainly renders the form to edit the item content in.
 */

import React from 'react';
import { Container, Spinner } from 'elemental';
import { connect } from 'react-redux';

import { listsByKey } from '../../../utils/lists';
import CreateForm from '../../shared/CreateForm';
import EditForm from './components/EditForm';
import EditFormHeader from './components/EditFormHeader';
import RelatedItemsList from './components/RelatedItemsList';
import FlashMessages from '../../shared/FlashMessages';

import {
	selectItem,
	loadItemData,
} from './actions';

import {
	selectList,
} from '../List/actions';

var ItemView = React.createClass({
	displayName: 'ItemView',
	contextTypes: {
		router: React.PropTypes.object.isRequired,
	},
	getInitialState () {
		return {
			createIsOpen: false,
		};
	},
	componentDidMount () {
		// When we directly navigate to an item without coming from another client
		// side routed page before, we need to select the list before initializing the item
		this.props.dispatch(selectList(this.props.params.listId));
		this.initializeItem(this.props.params.itemId);
	},
	componentWillReceiveProps (nextProps) {
		// We've opened a new item from the client side routing, so initialize
		// again with the new item id
		if (nextProps.params.itemId !== this.props.params.itemId) {
			this.initializeItem(nextProps.params.itemId);
		}
	},
	// Initialize an item
	initializeItem (itemId) {
		this.props.dispatch(selectItem(itemId));
		this.props.dispatch(loadItemData());
	},
	// Called when a new item is created
	onCreate (item) {
		// Hide the create form
		this.setState({
			createIsOpen: false,
		});
		// Redirect to newly created item path
		const list = this.props.currentList;
		this.context.router.push(`${Keystone.adminPath}/${list.path}/${item.id}`);
	},
	// Open and close the create new item modal
	toggleCreate (visible) {
		this.setState({
			createIsOpen: visible,
		});
	},
	// Render this items relationships
	renderRelationships () {
		const { relationships } = this.props.currentList;
		const keys = Object.keys(relationships);
		if (!keys.length) return;
		return (

				<Container>

Relationships

					{keys.map(key => {
						const relationship = relationships[key];
						// const refList = Lists[relationship.path];
						// return (
						// 	<RelatedItemsList
						// 		key={relationship.path}
						// 		list={this.props.currentList}
						// 		refList={refList}
						// 		relatedItemId={this.props.params.itemId}
						// 		relationship={relationship}
						// 	/>
						// );
					})}
				</Container>

		);
	},
	render () {
		// If we don't have any data yet, show the loading indicator
		if (!this.props.ready) {
			return (

					<Spinner size="md" />

			);
		}
		// When we have the data, render the item view with it
		return (

				{(this.props.error) ? (
					<FlashMessages
						messages={{
							error: [{
								title: "There's a problem with the network, we're trying to reconnect...",
							}],
						}}
					/>
				) : (

						<Container>
							<EditFormHeader
								list={this.props.currentList}
								data={this.props.data}
								toggleCreate={this.toggleCreate}
							/>
							<CreateForm
								list={this.props.currentList}
								isOpen={this.state.createIsOpen}
								onCancel={() => this.toggleCreate(false)}
								onCreate={(item) => this.onCreate(item)}
							/>
							<EditForm
								list={this.props.currentList}
								data={this.props.data}
								dispatch={this.props.dispatch}
								router={this.context.router}
							/>
						</Container>
						{this.renderRelationships()}

				)}

		);
	},
});

module.exports = connect((state) => ({
	data: state.item.data,
	loading: state.item.loading,
	ready: state.item.ready,
	error: state.item.error,
	currentList: state.lists.currentList,
}))(ItemView);
<commit_msg>Fixed relationship display<commit_after>/**
 * Item View
 *
 * This is the item view, it is rendered when users visit a page of a specific
 * item. This mainly renders the form to edit the item content in.
 */

import React from 'react';
import { Container, Spinner } from 'elemental';
import { connect } from 'react-redux';

import { listsByKey } from '../../../utils/lists';
import CreateForm from '../../shared/CreateForm';
import EditForm from './components/EditForm';
import EditFormHeader from './components/EditFormHeader';
import RelatedItemsList from './components/RelatedItemsList';
import FlashMessages from '../../shared/FlashMessages';

import {
	selectItem,
	loadItemData,
} from './actions';

import {
	selectList,
} from '../List/actions';

var ItemView = React.createClass({
	displayName: 'ItemView',
	contextTypes: {
		router: React.PropTypes.object.isRequired,
	},
	getInitialState () {
		return {
			createIsOpen: false,
		};
	},
	componentDidMount () {
		// When we directly navigate to an item without coming from another client
		// side routed page before, we need to select the list before initializing the item
		this.props.dispatch(selectList(this.props.params.listId));
		this.initializeItem(this.props.params.itemId);
	},
	componentWillReceiveProps (nextProps) {
		// We've opened a new item from the client side routing, so initialize
		// again with the new item id
		if (nextProps.params.itemId !== this.props.params.itemId) {
			this.initializeItem(nextProps.params.itemId);
		}
	},
	// Initialize an item
	initializeItem (itemId) {
		this.props.dispatch(selectItem(itemId));
		this.props.dispatch(loadItemData());
	},
	// Called when a new item is created
	onCreate (item) {
		// Hide the create form
		this.setState({
			createIsOpen: false,
		});
		// Redirect to newly created item path
		const list = this.props.currentList;
		this.context.router.push(`${Keystone.adminPath}/${list.path}/${item.id}`);
	},
	// Open and close the create new item modal
	toggleCreate (visible) {
		this.setState({
			createIsOpen: visible,
		});
	},
	// Render this items relationships
	renderRelationships () {
		const { relationships } = this.props.currentList;
		const keys = Object.keys(relationships);
		if (!keys.length) return;
		return (

				<Container>

Relationships

					{keys.map(key => {
						const relationship = relationships[key];
						const refList = listsByKey[relationship.ref];
						return (
							<RelatedItemsList
								key={relationship.path}
								list={this.props.currentList}
								refList={refList}
								relatedItemId={this.props.params.itemId}
								relationship={relationship}
							/>
						);
					})}
				</Container>

		);
	},
	render () {
		// If we don't have any data yet, show the loading indicator
		if (!this.props.ready) {
			return (

					<Spinner size="md" />

			);
		}
		// When we have the data, render the item view with it
		return (

				{(this.props.error) ? (
					<FlashMessages
						messages={{
							error: [{
								title: "There's a problem with the network, we're trying to reconnect...",
							}],
						}}
					/>
				) : (

						<Container>
							<EditFormHeader
								list={this.props.currentList}
								data={this.props.data}
								toggleCreate={this.toggleCreate}
							/>
							<CreateForm
								list={this.props.currentList}
								isOpen={this.state.createIsOpen}
								onCancel={() => this.toggleCreate(false)}
								onCreate={(item) => this.onCreate(item)}
							/>
							<EditForm
								list={this.props.currentList}
								data={this.props.data}
								dispatch={this.props.dispatch}
								router={this.context.router}
							/>
						</Container>
						{this.renderRelationships()}

				)}

		);
	},
});

module.exports = connect((state) => ({
	data: state.item.data,
	loading: state.item.loading,
	ready: state.item.ready,
	error: state.item.error,
	currentList: state.lists.currentList,
}))(ItemView);
<|endoftext|>


<commit_before>var util = require('util'),
  os = require('os'),
  PythonShell = require('python-shell'),
  exec = require('child_process').exec,
  bleno = require('bleno'),
  gpio = require("pi-gpio"),
  Descriptor = bleno.Descriptor,
  Characteristic = bleno.Characteristic;

var BatteryLevelCharacteristic = function() {
  BatteryLevelCharacteristic.super_.call(this, {
      uuid: '2A19',
      properties: ['read', 'write', 'notify'],
      descriptors: [
        new Descriptor({
            uuid: '2901',
            value: 'Battery level between 0 and 100 percent'
        }),
        new Descriptor({
            uuid: '2904',
            value: new Buffer([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
        })
      ]
  });
};

util.inherits(BatteryLevelCharacteristic, Characteristic);

BatteryLevelCharacteristic.prototype.onReadRequest = function(offset, callback) {

  console.log("in read");
  if (os.platform() === 'darwin') {
    exec('pmset -g batt', function (error, stdout, stderr) {

      var data = stdout.toString();
      // data - 'Now drawing from \'Battery Power\'\n -InternalBattery-0\t95%; discharging; 4:11 remaining\n'
      var percent = data.split('\t')[1].split(';')[0];
      console.log(percent);
      percent = parseInt(percent, 10);
      callback(this.RESULT_SUCCESS, new Buffer([percent]));

    });
  } else {
    // return hardcoded value
    console.log("reading...")
    callback(this.RESULT_SUCCESS, new Buffer([98]));

  }
};

BatteryLevelCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
  //console.log("in write");
  if (offset) {
    //console.log("in write - offset");
    callback(this.RESULT_ATTR_NOT_LONG);
  }
  //else if (data.length !== 1) {
   // console.log("data length !== 1");
    //console.log(JSON.stringify(data));
    //callback(this.RESULT_INVALID_ATTRIBUTE_LENGTH);
  //}
  else {
    // console.log(JSON.stringify(data));
    // console.log('processing write request');
    // var receivedData = data.readUInt8(0);
    // console.log(typeof data);
    // console.log(data.toString('ascii'));

    // console.log(receivedData);
    // console.log(typeof receivedData);
        var command = data.toString('ascii');
    //console.log('command');
    console.log(command);

    if(command === "0"){
      console.log("stop");
      // print "Now stop"
      // GPIO.output(Motor1E,GPIO.LOW)

          gpio.open(22, "output", function(err) {
          if(err){
            console.log(err);
          }       // Open pin 22 for output
          gpio.write(22, 0, function() {            // Set pin 22 low (0)
              console.log("set pin 22 low");
            //gpio.close(22);                        // Close pin 22
          });
        });

    }
    else if(command === "1"){
      console.log("command left");

            PythonShell.defaultOptions = {
              scriptPath: './gpiopython'
            };

            var pyshell = new PythonShell('pwm.py', {
                mode: 'text'
            });

            var output = '';
            pyshell.stdout.on('data', function (data) {
                output += ''+data;
                console.log(output);
            });

            pyshell.send('left').end(function (err) {
                if (err) return console.log(err);
                console.log(output);

            });

    }else if(command === "2"){
      console.log("command right");

            PythonShell.defaultOptions = {
              scriptPath: './gpiopython'
            };

            var pyshell = new PythonShell('pwm.py', {
                mode: 'text'.
                pythonOptions: '-u'
            });

            var output = '';
            pyshell.stdout.on('data', function (data) {
                output += ''+data;
                console.log(output);
            });

            pyshell.send('right').end(function (err) {
                if (err) return console.log(err);
                console.log(output);

            });
    }
    else if(command === "3"){
      console.log("forward");

          gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, 0, function() {            // Set pin 16 high (1)
                console.log("set pin 16 low");
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, 1, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 high");
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, 1, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 high");
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });

    }
    else if(command === "4"){
      console.log("back");
                gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, 1, function() {            // Set pin 16 high (1)
                console.log("set pin 16 high");
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, 0, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 low");
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, 1, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 high");
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });
    }

  }
  callback(this.RESULT_SUCCESS);
};

function setMotorDirection(direction) {
    console.log('Setting: ' + direction);

          var pin16 = 0;
          var pin18 = 0;
          var pin22 = 0;

          if(direction === 'forward'){
            pin16 = 1;
            pin18 = 0;
            pin22 = 1;
          }else if (direction == 'reverse'){
            pin16 = 1;
            pin18 = 0;
            pin22 = 1;
          }

          gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, pin16, function() {            // Set pin 16 high (1)
                console.log("set pin 16 " + pin16);
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, pin18, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 " + pin18);
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, pin22, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 " + pin22);
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });
}

BatteryLevelCharacteristic.prototype.onNotify = function() {
  console.log('NotifyOnlyCharacteristic on notify');
};

module.exports = BatteryLevelCharacteristic;
<commit_msg>python options<commit_after>var util = require('util'),
  os = require('os'),
  PythonShell = require('python-shell'),
  exec = require('child_process').exec,
  bleno = require('bleno'),
  gpio = require("pi-gpio"),
  Descriptor = bleno.Descriptor,
  Characteristic = bleno.Characteristic;

var BatteryLevelCharacteristic = function() {
  BatteryLevelCharacteristic.super_.call(this, {
      uuid: '2A19',
      properties: ['read', 'write', 'notify'],
      descriptors: [
        new Descriptor({
            uuid: '2901',
            value: 'Battery level between 0 and 100 percent'
        }),
        new Descriptor({
            uuid: '2904',
            value: new Buffer([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
        })
      ]
  });
};

util.inherits(BatteryLevelCharacteristic, Characteristic);

BatteryLevelCharacteristic.prototype.onReadRequest = function(offset, callback) {

  console.log("in read");
  if (os.platform() === 'darwin') {
    exec('pmset -g batt', function (error, stdout, stderr) {

      var data = stdout.toString();
      // data - 'Now drawing from \'Battery Power\'\n -InternalBattery-0\t95%; discharging; 4:11 remaining\n'
      var percent = data.split('\t')[1].split(';')[0];
      console.log(percent);
      percent = parseInt(percent, 10);
      callback(this.RESULT_SUCCESS, new Buffer([percent]));

    });
  } else {
    // return hardcoded value
    console.log("reading...")
    callback(this.RESULT_SUCCESS, new Buffer([98]));

  }
};

BatteryLevelCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
  //console.log("in write");
  if (offset) {
    //console.log("in write - offset");
    callback(this.RESULT_ATTR_NOT_LONG);
  }
  //else if (data.length !== 1) {
   // console.log("data length !== 1");
    //console.log(JSON.stringify(data));
    //callback(this.RESULT_INVALID_ATTRIBUTE_LENGTH);
  //}
  else {
    // console.log(JSON.stringify(data));
    // console.log('processing write request');
    // var receivedData = data.readUInt8(0);
    // console.log(typeof data);
    // console.log(data.toString('ascii'));

    // console.log(receivedData);
    // console.log(typeof receivedData);
        var command = data.toString('ascii');
    //console.log('command');
    console.log(command);

    if(command === "0"){
      console.log("stop");
      // print "Now stop"
      // GPIO.output(Motor1E,GPIO.LOW)

          gpio.open(22, "output", function(err) {
          if(err){
            console.log(err);
          }       // Open pin 22 for output
          gpio.write(22, 0, function() {            // Set pin 22 low (0)
              console.log("set pin 22 low");
            //gpio.close(22);                        // Close pin 22
          });
        });

    }
    else if(command === "1"){
      console.log("command left");

            PythonShell.defaultOptions = {
              scriptPath: './gpiopython'
            };

            var pyshell = new PythonShell('pwm.py', {
                mode: 'text'
            });

            var output = '';
            pyshell.stdout.on('data', function (data) {
                output += ''+data;
                console.log(output);
            });

            pyshell.send('left').end(function (err) {
                if (err) return console.log(err);
                console.log(output);

            });

    }else if(command === "2"){
      console.log("command right");

            PythonShell.defaultOptions = {
              scriptPath: './gpiopython'
            };

            var pyshell = new PythonShell('pwm.py', {
                pythonOptions: '-u'
            });

            var output = '';
            pyshell.stdout.on('data', function (data) {
                output += ''+data;
                console.log(output);
            });

            pyshell.send('right').end(function (err) {
                if (err) return console.log(err);
                console.log(output);

            });
    }
    else if(command === "3"){
      console.log("forward");

          gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, 0, function() {            // Set pin 16 high (1)
                console.log("set pin 16 low");
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, 1, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 high");
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, 1, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 high");
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });

    }
    else if(command === "4"){
      console.log("back");
                gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, 1, function() {            // Set pin 16 high (1)
                console.log("set pin 16 high");
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, 0, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 low");
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, 1, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 high");
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });
    }

  }
  callback(this.RESULT_SUCCESS);
};

function setMotorDirection(direction) {
    console.log('Setting: ' + direction);

          var pin16 = 0;
          var pin18 = 0;
          var pin22 = 0;

          if(direction === 'forward'){
            pin16 = 1;
            pin18 = 0;
            pin22 = 1;
          }else if (direction == 'reverse'){
            pin16 = 1;
            pin18 = 0;
            pin22 = 1;
          }

          gpio.open(16, "output", function(err) {
            if(err){
              console.log(err);
            }       // Open pin 16 for output
            gpio.write(16, pin16, function() {            // Set pin 16 high (1)
                console.log("set pin 16 " + pin16);
              //gpio.close(16);                        // Close pin 16
              //18
              gpio.open(18, "output", function(err) {
                if(err){
                  console.log(err);
                }       // Open pin 18 for output
                gpio.write(18, pin18, function() {            // Set pin 18 low (0)
                    console.log("set pin 18 " + pin18);
                  //gpio.close(18);                        // Close pin 18
                    gpio.open(22, "output", function(err) {
                          if(err){
                            console.log(err);
                          }       // Open pin 22 for output
                          gpio.write(22, pin22, function() {            // Set pin 22 high (1)
                              console.log("set pin 22 " + pin22);
                            //gpio.close(22);                        // Close pin 22
                          });
                        });
                });
              });
            });
          });
}

BatteryLevelCharacteristic.prototype.onNotify = function() {
  console.log('NotifyOnlyCharacteristic on notify');
};

module.exports = BatteryLevelCharacteristic;
<|endoftext|>