<commit_before>!function() {

var gantplanning={
	version:"0.1.0"
};

var Planning=function()
{
	var currentMoveDirection=undefined;
	var _this=this;
	var timeToCoordinate;
	var dragged;

	this.style={
		phaseColor:d3.rgb("#083968"),
		stepWidth:"auto",
		phaseHeight:35,
		textColor:d3.rgb("#F7F7F7"),
		phaseY:30,
		svgWidth:700,
		fontsize:16,
		offsetTextY:21,
		weekColor:d3.rgb("#083968"),
		weekBarColor:d3.rgb("#999999")
	};

	this.params={
		sticky:0.1,
		minWeeks:6,
		border:0.3,
		week:"Semaine",
		showWeeks:true
	}

	var calcTimeToCoordinate=function()
	{
		if (_this.style.stepWidth=="auto")
			timeToCoordinate=d3.scale.linear()
				.domain([0,_this.weeks])
				.range([0,_this.style.svgWidth])
		else
			timeToCoordinate = d3.scale.linear()
				.domain([0,1])
				.range([0,_this.style.stepWidth]);
	}

	this.setStepWidth=function(stepWidth)
	{
		this.style.stepWidth=stepWidth;
		calcTimeToCoordinate();
	}

	var cleanPhase=function(phase) {
		phase.dx=0;
		phase.dy=0;
		return phase;
	}

	this.fill=function(phases) {
		this.phases=phases;
		for(i=0;i<this.phases.length;i++){
			this.phases[i]=cleanPhase(this.phases[i]);
		}
		return this;
	}

	this.addPhase=function(phase) {
		this.phases.push(cleanPhase(phase));
		this.draw()
	}

	this.attachTo=function(element) {
		this.element=element;
		this.mainElement= d3.select(this.element)
			.attr("class","gant-planning");
		return this;
	}

	var detectMoveDirection=function(xleft,width){
		if (Math.abs(xleft)<_this.params.border*_this.style.stepWidth) {
				return "left";
			}
		var xright=xleft-width;

		if (Math.abs(xright)<_this.params.border*_this.style.stepWidth) {
				return "right";
			}
		return "none";
	}

	var drag = d3.behavior.drag()
		.on("dragstart", function(d,i) {
			var type=d3.event.sourceEvent.target.nodeName;
			var xleft = d3.event.sourceEvent.offsetX==undefined?d3.event.sourceEvent.layerX:d3.event.sourceEvent.offsetX;
			xleft-=d.x;
			if (type=="text")
				currentMoveDirection="none";
			else
				currentMoveDirection=detectMoveDirection(xleft,d.width);
			dragged=false;
		})
		.on("drag", function(d,i) {
			dragged=true;
			d.dx+=d3.event.dx;

			//Sticky edges
			var difference=Math.round(timeToCoordinate.invert(d.dx))-timeToCoordinate.invert(d.dx);
			var distance=Math.abs(difference);
			if (distance<_this.params.sticky) {
					d.rx= timeToCoordinate(Math.round(timeToCoordinate.invert(d.dx)));
				}
			else {
					d.rx=d.dx;
				}

			if (currentMoveDirection=="none") {
				if(d.start+timeToCoordinate.invert(d.rx)<=0)
					d.rx=-timeToCoordinate(d.start);
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("x",function(v){return (v.x+d.rx)})
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx)})
			}

			if (currentMoveDirection=="right") {
				if (d.end-d.start+timeToCoordinate.invert(d.rx)<=1) {
					d.rx=timeToCoordinate(d.start-d.end+1);
				}
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("width",function(v){return (v.width+d.rx)+"px"})
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx/2)+"px"})
			}
			if (currentMoveDirection=="left") {
				if (d.end-d.start-timeToCoordinate.invert(d.rx)<=1) {
					d.rx=timeToCoordinate(d.end-d.start-1);
				}
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx/2)+"px"})
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("x",function(v){return (v.x+d.rx)+"px"})
					.attr("width",function(v){return (v.width-d.rx)+"px"})
			}
		})
		.on("dragend",function(d,i) {
			if (dragged==false)
			{
				return true;
			}
			for(i=0;i<_this.phases.length;i++) {
				var phase=_this.phases[i];
				if (phase.dx!=0)
				{
					if(currentMoveDirection=="none") {
						phase.x+=phase.rx;
						var newStart=Math.round(timeToCoordinate.invert(phase.x));
						phase.end=newStart+phase.end-phase.start;
						phase.start=newStart;
						currentMoveDirection=undefined;
					}
					if (currentMoveDirection=="right") {
						phase.end=Math.round(timeToCoordinate.invert(phase.x+phase.width+phase.rx));
						if (phase.end<phase.start+1) phase.end=phase.start+1;
						currentMoveDirection=undefined;
					}
					if (currentMoveDirection=="left") {
						phase.start=Math.round(timeToCoordinate.invert(phase.x+phase.rx));
						if (phase.start>phase.end-1) phase.start=phase.end-1;
						currentMoveDirection=undefined;
					}
				}
				phase.dx=0;
				phase.rx=0;
			}
			_this.draw();
			currentMoveDirection=undefined;
		});

	var reorderPhases=function() {
		_this.phases.sort(function(a,b){
			var x = a.start+1/100*a.end;
			var y = b.start+1/100*b.end;
			if (x<y) return -1;
			if (x>y) return 1;
			if (a.description<b.description) return -1;
			if (a.description>b.description) return 1;
			return -1;
		});
	}

	var calcCoordinates=function() {
		for(i=0;i<_this.phases.length;i++) {
			var phase=_this.phases[i];
			phase.x=timeToCoordinate(phase.start);
			phase.textx=timeToCoordinate((phase.start+phase.end)/2);
			phase.width=timeToCoordinate(phase.end-phase.start);
			phase.y=_this.style.phaseY+i*_this.style.phaseHeight;
			phase.texty=_this.style.phaseY+_this.style.offsetTextY+i*_this.style.phaseHeight;
			_this.phases[i]=phase;
		}
	}

	var updatePhases=function() {
		var phases=_this.mainElement.selectAll("rect.phase")
			.data(_this.phases);

		phases.enter()
			.append("rect")
			.attr("class",function(v,i){return "phase phase-"+i})
			.attr("fill",_this.style.phaseColor)
			.attr("height",_this.style.phaseHeight+"px")
			.attr("y",function(v){return v.y+"px"})
			.on("mousemove",function(d,i){
				var type=d3.event.target.nodeName;
				var xleft = d3.event.offsetX==undefined?d3.event.layerX:d3.event.offsetX;
				if (type=="rect")
					xleft-=d.x;
				if (type=="text")
					xleft-=d.x;
				if (currentMoveDirection==undefined)
					var moveDirection=detectMoveDirection(xleft,d.width)
				else
					var moveDirection=currentMoveDirection;
				d3.select(this)
					.attr("class",function(v){return "phase phase-"+i+" stretch-"+moveDirection})
			});

		phases
			.attr("width",function(v){return v.width+"px"})
			.attr("x",function(v){return v.x+"px"})
			.attr("y",function(v){return v.y+"px"})
			.call(drag);
	}

	var updateDescriptions=function() {
		var descriptions=_this.mainElement.selectAll("text.phase-description")
			.data(_this.phases);

		descriptions.enter()
			.append("text")
			.attr("class",function(v,i){return "phase-description phase-"+i})
			.attr("text-anchor","middle")
			.attr("font-size",_this.style.fontsize)
			.attr("fill",_this.style.textColor)
			.on("mousemove",function(d,i){
				if (currentMoveDirection==undefined)
					var moveDirection="none";
				else
					var moveDirection=currentMoveDirection;
				d3.select(this)
					.attr("class",function(v){return "phase-description phase-"+i+" stretch-"+moveDirection})
			});

		descriptions
			.attr("x",function(v,i){return v.textx+"px"})
			.attr("y",function(v,i){return v.texty+"px"})
			.text(function(d){return d.description})
			.on("click",function(){ if (dragged==false) alert('edit'); })
			.call(drag)
	}

	this.setWeeks=function(n)
	{
		if (n===undefined) n=0;
		this.weeks=Math.max(n,this.params.minWeeks);
	}

	this.drawWeeks=function()
	{
		var weeks=Array.apply(null, {length: _this.weeks}).map(Number.call, Number);
		var weeksForBars=Array.apply(null, {length: _this.weeks+1}).map(Number.call, Number);

		var weekDescriptions=_this.mainElement.selectAll("text.week-description")
			.data(weeks);

		weekDescriptions.enter().append("text")
			.attr("class","week-description");

		weekDescriptions
			.attr("text-anchor","middle")
			.attr("font-size",_this.style.fontsize)
			.attr("fill",_this.style.weekColor)
			.attr("x",function(w){return timeToCoordinate(w+0.5);})
			.attr("y",17)
			.text(function(d){return _this.params.week+" "+(d+1)});

		var weekBars=_this.mainElement.selectAll("rect.week.bars")
			.data(weeksForBars);

		weekBars.enter().append("rect")
			.attr("class","week bars");

		weekBars
			.attr("width",2)
			.attr("height",12)
			.attr("y",12)
			.attr("x",function(w){return timeToCoordinate(w);})
			.attr("fill",_this.style.weekBarColor);

		weekBars.exit().remove();
	}

	this.draw=function() {
		reorderPhases();
		if (this.params.showWeeks==true) {
			this.setWeeks()
		}
		calcTimeToCoordinate();
		if (this.params.showWeeks==true) {
			this.drawWeeks();
		}
		calcCoordinates();
		updatePhases();
		updateDescriptions();
		return this;
	}

	dragged=false;
	this.phases=[];
}

gantplanning.createPlanning=function(planning) {
	return new Planning();
}

this.gantplanning=gantplanning;
}()
<commit_msg>resize behavior works again well<commit_after>!function() {

var gantplanning={
	version:"0.1.0"
};

var Planning=function()
{
	var currentMoveDirection=undefined;
	var _this=this;
	var timeToCoordinate;
	var dragged;

	this.style={
		phaseColor:d3.rgb("#083968"),
		stepWidth:"auto",
		phaseHeight:35,
		textColor:d3.rgb("#F7F7F7"),
		phaseY:30,
		svgWidth:700,
		fontsize:16,
		offsetTextY:21,
		weekColor:d3.rgb("#083968"),
		weekBarColor:d3.rgb("#999999")
	};

	this.params={
		sticky:0.1,
		minWeeks:6,
		border:0.3,
		week:"Semaine",
		showWeeks:true
	}

	var calcTimeToCoordinate=function()
	{
		if (_this.style.stepWidth=="auto")
			timeToCoordinate=d3.scale.linear()
				.domain([0,_this.weeks])
				.range([0,_this.style.svgWidth])
		else
			timeToCoordinate = d3.scale.linear()
				.domain([0,1])
				.range([0,_this.style.stepWidth]);
	}

	this.setStepWidth=function(stepWidth)
	{
		this.style.stepWidth=stepWidth;
		calcTimeToCoordinate();
	}

	var cleanPhase=function(phase) {
		phase.dx=0;
		phase.dy=0;
		return phase;
	}

	this.fill=function(phases) {
		this.phases=phases;
		for(i=0;i<this.phases.length;i++){
			this.phases[i]=cleanPhase(this.phases[i]);
		}
		return this;
	}

	this.addPhase=function(phase) {
		this.phases.push(cleanPhase(phase));
		this.draw()
	}

	this.attachTo=function(element) {
		this.element=element;
		this.mainElement= d3.select(this.element)
			.attr("class","gant-planning");
		return this;
	}

	var detectMoveDirection=function(xleft,width){
		if (Math.abs(xleft)<_this.params.border*timeToCoordinate(1)) {
				return "left";
			}
		var xright=xleft-width;

		if (Math.abs(xright)<_this.params.border*timeToCoordinate(1)) {
				return "right";
			}
		return "none";
	}

	var calcMaxWeek=function(phases)
	{
		var max=phases[0].end;
		phases.forEach(function(phase){
			max=Math.max(max,phase.end);
		});
		return max;
	}

	var drag = d3.behavior.drag()
		.on("dragstart", function(d,i) {
			var type=d3.event.sourceEvent.target.nodeName;
			var xleft = d3.event.sourceEvent.offsetX==undefined?d3.event.sourceEvent.layerX:d3.event.sourceEvent.offsetX;
			xleft-=d.x;
			if (type=="text")
				currentMoveDirection="none";
			else
				currentMoveDirection=detectMoveDirection(xleft,d.width);
			dragged=false;
		})
		.on("drag", function(d,i) {
			dragged=true;
			d.dx+=d3.event.dx;

			//Sticky edges
			var difference=Math.round(timeToCoordinate.invert(d.dx))-timeToCoordinate.invert(d.dx);
			var distance=Math.abs(difference);
			if (distance<_this.params.sticky) {
					d.rx= timeToCoordinate(Math.round(timeToCoordinate.invert(d.dx)));
				}
			else {
					d.rx=d.dx;
				}

			if (currentMoveDirection=="none") {
				if(d.start+timeToCoordinate.invert(d.rx)<=0)
					d.rx=-timeToCoordinate(d.start);
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("x",function(v){return (v.x+d.rx)})
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx)})
			}

			if (currentMoveDirection=="right") {
				if (d.end-d.start+timeToCoordinate.invert(d.rx)<=1) {
					d.rx=timeToCoordinate(d.start-d.end+1);
				}
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("width",function(v){return (v.width+d.rx)+"px"})
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx/2)+"px"})
			}
			if (currentMoveDirection=="left") {
				if (d.end-d.start-timeToCoordinate.invert(d.rx)<=1) {
					d.rx=timeToCoordinate(d.end-d.start-1);
				}
				_this.mainElement.selectAll(".phase-description.phase-"+i)
					.attr("x",function(v){return (v.textx+d.rx/2)+"px"})
				_this.mainElement.selectAll(".phase.phase-"+i)
					.attr("x",function(v){return (v.x+d.rx)+"px"})
					.attr("width",function(v){return (v.width-d.rx)+"px"})
			}
		})
		.on("dragend",function(d,i) {
			if (dragged==false)
			{
				return true;
			}
			for(i=0;i<_this.phases.length;i++) {
				var phase=_this.phases[i];
				if (phase.dx!=0)
				{
					if(currentMoveDirection=="none") {
						phase.x+=phase.rx;
						var newStart=Math.round(timeToCoordinate.invert(phase.x));
						phase.end=newStart+phase.end-phase.start;
						phase.start=newStart;
						currentMoveDirection=undefined;
					}
					if (currentMoveDirection=="right") {
						phase.end=Math.round(timeToCoordinate.invert(phase.x+phase.width+phase.rx));
						if (phase.end<phase.start+1) phase.end=phase.start+1;
						currentMoveDirection=undefined;
					}
					if (currentMoveDirection=="left") {
						phase.start=Math.round(timeToCoordinate.invert(phase.x+phase.rx));
						if (phase.start>phase.end-1) phase.start=phase.end-1;
						currentMoveDirection=undefined;
					}
				}
				phase.dx=0;
				phase.rx=0;
			}
			_this.draw();
			currentMoveDirection=undefined;
		});

	var reorderPhases=function() {
		_this.phases.sort(function(a,b){
			var x = a.start+1/100*a.end;
			var y = b.start+1/100*b.end;
			if (x<y) return -1;
			if (x>y) return 1;
			if (a.description<b.description) return -1;
			if (a.description>b.description) return 1;
			return -1;
		});
	}

	var calcCoordinates=function() {
		for(i=0;i<_this.phases.length;i++) {
			var phase=_this.phases[i];
			phase.x=timeToCoordinate(phase.start);
			phase.textx=timeToCoordinate((phase.start+phase.end)/2);
			phase.width=timeToCoordinate(phase.end-phase.start);
			phase.y=_this.style.phaseY+i*_this.style.phaseHeight;
			phase.texty=_this.style.phaseY+_this.style.offsetTextY+i*_this.style.phaseHeight;
			_this.phases[i]=phase;
		}
	}

	var updatePhases=function() {
		var phases=_this.mainElement.selectAll("rect.phase")
			.data(_this.phases);

		phases.enter()
			.append("rect")
			.attr("class",function(v,i){return "phase phase-"+i})
			.attr("fill",_this.style.phaseColor)
			.attr("height",_this.style.phaseHeight+"px")
			.attr("y",function(v){return v.y+"px"})
			.on("mousemove",function(d,i){
				var type=d3.event.target.nodeName;
				var xleft = d3.event.offsetX==undefined?d3.event.layerX:d3.event.offsetX;
				if (type=="rect")
					xleft-=d.x;
				if (type=="text")
					xleft-=d.x;
				if (currentMoveDirection==undefined)
					var moveDirection=detectMoveDirection(xleft,d.width)
				else
					var moveDirection=currentMoveDirection;
				d3.select(this)
					.attr("class",function(v){return "phase phase-"+i+" stretch-"+moveDirection})
			});

		phases
			.attr("width",function(v){return v.width+"px"})
			.attr("x",function(v){return v.x+"px"})
			.attr("y",function(v){return v.y+"px"})
			.call(drag);
	}

	var updateDescriptions=function() {
		var descriptions=_this.mainElement.selectAll("text.phase-description")
			.data(_this.phases);

		descriptions.enter()
			.append("text")
			.attr("class",function(v,i){return "phase-description phase-"+i})
			.attr("text-anchor","middle")
			.attr("font-size",_this.style.fontsize)
			.attr("fill",_this.style.textColor)
			.on("mousemove",function(d,i){
				if (currentMoveDirection==undefined)
					var moveDirection="none";
				else
					var moveDirection=currentMoveDirection;
				d3.select(this)
					.attr("class",function(v){return "phase-description phase-"+i+" stretch-"+moveDirection})
			});

		descriptions
			.attr("x",function(v,i){return v.textx+"px"})
			.attr("y",function(v,i){return v.texty+"px"})
			.text(function(d){return d.description})
			.on("click",function(){ if (dragged==false) alert('edit'); })
			.call(drag)
	}

	this.setWeeks=function(n)
	{
		if (n===undefined) n=0;
		this.weeks=Math.max(n,this.params.minWeeks);
	}

	this.drawWeeks=function()
	{
		var weeks=Array.apply(null, {length: _this.weeks}).map(Number.call, Number);
		var weeksForBars=Array.apply(null, {length: _this.weeks+1}).map(Number.call, Number);

		var weekDescriptions=_this.mainElement.selectAll("text.week-description")
			.data(weeks);

		weekDescriptions.enter().append("text")
			.attr("class","week-description");

		weekDescriptions
			.attr("text-anchor","middle")
			.attr("font-size",_this.style.fontsize)
			.attr("fill",_this.style.weekColor)
			.attr("x",function(w){return timeToCoordinate(w+0.5);})
			.attr("y",17)
			.text(function(d){return _this.params.week+" "+(d+1)});

		var weekBars=_this.mainElement.selectAll("rect.week.bars")
			.data(weeksForBars);

		weekBars.enter().append("rect")
			.attr("class","week bars");

		weekBars
			.attr("width",2)
			.attr("height",12)
			.attr("y",12)
			.attr("x",function(w){return timeToCoordinate(w);})
			.attr("fill",_this.style.weekBarColor);

		weekBars.exit().remove();
	}

	this.draw=function() {
		reorderPhases();
		if (this.params.showWeeks==true) {
			this.setWeeks()
		}
		calcTimeToCoordinate();
		if (this.params.showWeeks==true) {
			this.drawWeeks();
		}
		calcCoordinates();
		updatePhases();
		updateDescriptions();
		return this;
	}

	dragged=false;
	this.phases=[];
}

gantplanning.createPlanning=function(planning) {
	return new Planning();
}

this.gantplanning=gantplanning;
}()
<|endoftext|>


<commit_before>module.exports = {
  siteMetadata: {
    url: 'https://livvy.byb.kr',
    title: '현지와 용배의 블로그',
    subtitle: '현지와 용배의 블로그',
    copyright: '© 2017 livvy & ybbarng All rights reserved.',
    disqusShortname: 'blog-of-livvy-and-ybbarng',
    menu: [
      {
        label: 'Home',
        path: '/'
      },
      {
        label: '잡담',
        path: '/category/smalltalk'
      },
      {
        label: '공부',
        path: '/category/study'
      },
      {
        label: '같이 놀기',
        path: '/category/date'
      }
    ],
    group: {
      name: '현지 & 용배'
    },
    authors: [
      {
        id: 'livvy',
        name: '현지',
        about: '/about-livvy/',
        github: '#',
        email: '#',
        keybase: '#',
        facebook: '#',
        twitter: '#',
        rss: '#'
      },
      {
        id: 'ybbarng',
        name: '용배',
        about: '/about-ybbarng/',
        github: '#',
        email: '#',
        keybase: '#',
        facebook: '#',
        twitter: '#',
        rss: '#'
      }
    ]
  },
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages'
      }
    },
    {
      resolve: 'gatsby-plugin-feed',
      options: {
        query: `
          {
            site {
              siteMetadata {
                url
                title
                subtitle
              }
            }
          }
        `,
        feeds: [
          {
            serialize: ({ query: { site, allMarkdownRemark } }) => (
              allMarkdownRemark.edges.map(edge =>
                Object.assign({}, edge.node.frontmatter, {
                  description: edge.node.frontmatter.description,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.url + edge.node.fields.slug,
                  guid: site.siteMetadata.url + edge.node.fields.slug,
                  custom_elements: [{ 'content:encoded': edge.node.html }]
                })
              )
            ),
            query: `
              {
                allMarkdownRemark(
                  limit: 1000,
                  sort: { order: DESC, fields: [frontmatter___date] },
                  filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } }
                ) {
                  edges {
                    node {
                      html
                      fields {
                        slug
                      }
                      frontmatter {
                        title
                        date
                        layout
                        draft
                        description
                      }
                    }
                  }
                }
              }
            `,
            output: '/rss.xml'
          }
        ]
      }
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 960,
              linkImagesToOriginal: false
            }
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
            options: {
              wrapperStyle: 'margin-bottom: 1.0725rem'
            }
          },
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
          'gatsby-remark-emoji'
        ]
      }
    },
    'gatsby-transformer-sharp',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: ''
      }
    },
    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
            {
              site {
                siteMetadata {
                  url
                }
              }
              allSitePage(
                filter: {
                  path: { regex: "/^(?!/404/|/404.html|/dev-404-page/)/" }
                }
              ) {
                edges {
                  node {
                    path
                  }
                }
              }
          }`,
        output: '/sitemap.xml',
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map((edge) => {
            return {
              url: site.siteMetadata.url + edge.node.path,
              changefreq: 'daily',
              priority: 0.7
            };
          })
      }
    },
    'gatsby-plugin-offline',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-postcss-sass'
  ]
};
<commit_msg>GA 추가<commit_after>module.exports = {
  siteMetadata: {
    url: 'https://livvy.byb.kr',
    title: '현지와 용배의 블로그',
    subtitle: '현지와 용배의 블로그',
    copyright: '© 2017 livvy & ybbarng All rights reserved.',
    disqusShortname: 'blog-of-livvy-and-ybbarng',
    menu: [
      {
        label: 'Home',
        path: '/'
      },
      {
        label: '잡담',
        path: '/category/smalltalk'
      },
      {
        label: '공부',
        path: '/category/study'
      },
      {
        label: '같이 놀기',
        path: '/category/date'
      }
    ],
    group: {
      name: '현지 & 용배'
    },
    authors: [
      {
        id: 'livvy',
        name: '현지',
        about: '/about-livvy/',
        github: '#',
        email: '#',
        keybase: '#',
        facebook: '#',
        twitter: '#',
        rss: '#'
      },
      {
        id: 'ybbarng',
        name: '용배',
        about: '/about-ybbarng/',
        github: '#',
        email: '#',
        keybase: '#',
        facebook: '#',
        twitter: '#',
        rss: '#'
      }
    ]
  },
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages'
      }
    },
    {
      resolve: 'gatsby-plugin-feed',
      options: {
        query: `
          {
            site {
              siteMetadata {
                url
                title
                subtitle
              }
            }
          }
        `,
        feeds: [
          {
            serialize: ({ query: { site, allMarkdownRemark } }) => (
              allMarkdownRemark.edges.map(edge =>
                Object.assign({}, edge.node.frontmatter, {
                  description: edge.node.frontmatter.description,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.url + edge.node.fields.slug,
                  guid: site.siteMetadata.url + edge.node.fields.slug,
                  custom_elements: [{ 'content:encoded': edge.node.html }]
                })
              )
            ),
            query: `
              {
                allMarkdownRemark(
                  limit: 1000,
                  sort: { order: DESC, fields: [frontmatter___date] },
                  filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } }
                ) {
                  edges {
                    node {
                      html
                      fields {
                        slug
                      }
                      frontmatter {
                        title
                        date
                        layout
                        draft
                        description
                      }
                    }
                  }
                }
              }
            `,
            output: '/rss.xml'
          }
        ]
      }
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 960,
              linkImagesToOriginal: false
            }
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
            options: {
              wrapperStyle: 'margin-bottom: 1.0725rem'
            }
          },
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
          'gatsby-remark-emoji'
        ]
      }
    },
    'gatsby-transformer-sharp',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: 'UA-93238645-3'
      }
    },
    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
            {
              site {
                siteMetadata {
                  url
                }
              }
              allSitePage(
                filter: {
                  path: { regex: "/^(?!/404/|/404.html|/dev-404-page/)/" }
                }
              ) {
                edges {
                  node {
                    path
                  }
                }
              }
          }`,
        output: '/sitemap.xml',
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map((edge) => {
            return {
              url: site.siteMetadata.url + edge.node.path,
              changefreq: 'daily',
              priority: 0.7
            };
          })
      }
    },
    'gatsby-plugin-offline',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-postcss-sass'
  ]
};
<|endoftext|>


<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @author mig <michel.gutierrez@gmail.com>
* @module jquery-jocly
* @overview Board game site integration.
*/

(function($) {

	var iframeIdRef = 1;

	function Applet(jqElm) {
		this.jqElm = jqElm;
		this.ready = false;
		this.queuedMessages = [];
	}
	Applet.prototype.init = function(options) {
		var $this=this;
		this.options = {
			//width : '100%',
			//height : 450,
			mode : "splash",
			maxWidth: 1000,
			ratio: 1,
			baseURL: "http://embed.jocly.net",
			masked: false,
		}
		if (options)
			$.extend(this.options, options);
		var iframeUrl = this.options.baseURL+"/jocly/plazza/embed";
		if(this.options.game)
			iframeUrl+="/"+this.options.game;
		iframeUrl+="?mode=" + this.options.mode;
		this.iframeId = iframeIdRef++;
		this.options.jei = this.iframeId;
		this.listener=function(event) {
			if(event.origin!=$this.options.baseURL || event.data.jei!=$this.iframeId)
				return;
			$this.messageListener(event.data);
		}
		window.addEventListener("message",this.listener,false);
		var iframeName = "jocly-iframe-" + this.iframeId;
		this.iframe = $("<iframe/>").attr("name", iframeName).attr(
				"frameborder", 0).attr("src", "about:blank");
		this.content = this.jqElm.html();
		this.jqElm.empty();

		var canvas=$("<canvas/>").attr("width",this.options.maxWidth).attr("height",this.options.maxWidth*this.options.ratio);
		var image=new Image();
		image.src = canvas[0].toDataURL("image/png");

		this.wrapper=$("<div/>").css({
			position: "relative",
			"white-space": "nowrap",
		}).appendTo(this.jqElm);

		this.wrapper.append($(image).css({
			width: "auto",
			height: "auto",
			"max-width": "100%",
			"max-height": "100%",
			"vertical-align": "bottom",
		}));

		this.container=$("<div/>").css("padding-top",this.options.ratio*100+"%").appendTo(
			$("<div/>").css({
				position: "absolute",
				top: 0,
				bottom: 0,
				left: 0,
				right: 0,
			}).appendTo(this.wrapper)
		);

		this.iframe.attr("width","100%").attr("height","100%").css({
			position: "absolute",
			top: 0,
			right: 0,
			bottom: 0,
			left: 0,
			"white-space": "normal",
		}).appendTo(this.container);

		this.maskElm=$("<div/>").css({
			display: this.options.masked?"block":"none",
			position: "absolute",
			top: 0,
			right: 0,
			width: "100%",
			height: "100%",
			'background-color': 'rgba(0,0,0,.8)',
			"z-index": 1,
		}).appendTo(this.wrapper);

		var initForm = $("<form/>").attr("action", iframeUrl).attr("method",
				"post").attr("target", iframeName);
		$("<input/>").attr("type", "hidden").attr("name", "data").attr("value",
				JSON.stringify(this.options)).appendTo(initForm);
		initForm.appendTo($("body"));
		initForm[0].submit();
		initForm.remove();
	}
	Applet.prototype.remove = function() {
		window.removeEventListener("message",this.listener,false);
		this.jqElm.empty();
		this.jqElm.html(this.content);
		this.jqElm.data("jocly-applet", null);
	}
	Applet.prototype.update = function(options) {
		this.remove();
		this.init(options);
	}
	Applet.prototype.messageListener = function(message) {
		console.log("jocly-applet received message from iframe",message);
		switch(message.type) {
		case 'ready':
			this.ready=true;
			this.queuedMessages.forEach(function(message) {
				this.sendMessage(message);
			},this);
			this.queuedMessages=[];
			break;
		case 'display':
			if(message.initial || message.moves) {
				var crc=$.joclyCRC32(message.initial || '');
				if(message.moves)
					message.moves.forEach(function(move) {
						crc=$.joclyCRC32(move.str,crc);
					});
				$(".jocly-listener").trigger('jocly',{
					type: 'display',
					crc: crc,
				});
			} else
				$(".jocly-listener").trigger('jocly',{
					type: 'undisplay',
				});
			break;
		case 'snapshot':
			var callback=this.snapshotCallbacks[message.snapshotId];
			delete this.snapshotCallbacks[message.snapshotId];
			if(message.image) {
				var image=new Image();
				image.onload=function() {
					console.log("image",image.width,"x",image.height)
					callback(image);
				}
				image.src=message.image;
			} else
				callback(null);
			break;
		default:
			$(".jocly-listener").trigger('jocly',message);
		}
	}
	Applet.prototype.sendMessage = function(message) {
		if(this.ready)
			this.iframe[0].contentWindow.postMessage(message,this.options.baseURL);
		else
			this.queuedMessages.push(message);
	}
	Applet.prototype.view = function(gameName,spec) {
		this.sendMessage({
			type: "view",
			gameName: gameName,
			data: spec,
		});
	}
	Applet.prototype.localPlay = function(gameName,spec) {
		this.sendMessage({
			type: "localPlay",
			gameName: gameName,
			data: spec || {},
		});
	}
	Applet.prototype.setFeatures = function(features) {
		this.sendMessage({
			type: "features",
			features: features,
		});
	}
	Applet.prototype.getId = function() {
		return this.iframeId;
	}
	Applet.prototype.emptyBoard = function(gameName) {
		this.sendMessage({
			type: "emptyBoard",
			gameName: gameName,
		});
	}
	Applet.prototype.viewOptions = function(options) {
		this.sendMessage({
			type: "viewOptions",
			options: options,
		});
	}
	Applet.prototype.mask = function(masked) {
		if(masked)
			this.maskElm.show();
		else
			this.maskElm.hide();
	}
	Applet.prototype.updateCamera = function(camera,delay) {
		this.sendMessage({
			type: "updateCamera",
			camera: camera,
			delay: delay,
		});
	}
	Applet.prototype.snapshotCallbacks={};
	Applet.prototype.snapshot = function(callback) {
		var snapshotId=1;
		while(snapshotId in this.snapshotCallbacks)
			snapshotId++;
		this.snapshotCallbacks[snapshotId]=callback;
		this.sendMessage({
			type: "snapshot",
			snapshotId: snapshotId,
		});
	}

	$.fn.jocly = function() {
		var $arguments = arguments;
		var retVal = this;
		this.each(function() {
			var applet = $(this).data("jocly-applet");
			var justCreated=false;
			if (!applet) {
				applet = new Applet($(this));
				justCreated=true;
				var options = $arguments[0] || null;
				var dataAttr = $(this).attr("data-jocly");
				if (dataAttr)
					try {
						options = eval("(" + dataAttr + ")"); // jshint ignore:line
					} catch (e) {
						console
								.error("Jocly applet: invalid data-jocly "
										+ dataAttr);
					}
				applet.init(options);
				$(this).data("jocly-applet", applet);
			}
			if ($arguments.length > 0) {
				var method = $arguments[0];
				if(justCreated && typeof method == "object")
					return;
				if (typeof method != "string")
					throw new Error(
							"Jocly applet: first argument must be a string specifying the method to be called");
				if (typeof applet[method] != "function")
					throw new Error("Jocly applet: no such method '"
							+ method + "'");
				var retVal0 = applet[method].apply(applet, Array.prototype.splice
						.call($arguments, 1));
				if(retVal0 !== undefined)
					console.log("method",method,"returns",retVal0)
			}
		});
		return retVal;
	};

	$(document).ready(function() {

		$("[data-jocly]").each(function() {
			var $this=$(this);
			$this.jocly();
			if(this.hasAttribute("data-jocly-init")) {
				var attr=$this.attr("data-jocly-init");
				if(attr.length===0)
					return;
				try {
					var arr=JSON.parse(attr);
					try {
						if(!Array.isArray(arr)) {
							console.warn("jquery.jocly: data-jocly-init attribute is not an array");
						}
						for(var i=0;i<arr.length;i++) {
							var element=arr[i];
							if(Array.isArray(element))
								$this.jocly.apply($this,element);
							else {
								$this.jocly.apply($this,arr);
								return;
							}
						}
					} catch(e) {
						console.warn("jquery.jocly: data-jocly-init error:",e);
					}
				} catch(e) {
					console.warn("jquery.jocly: data-jocly-init attribute has no JSON valid value");
				}
			}
		});

	});

}(jQuery));

<commit_msg>added getCamera method<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @author mig <michel.gutierrez@gmail.com>
* @module jquery-jocly
* @overview Board game site integration.
*/

(function($) {

	var iframeIdRef = 1;

	function Applet(jqElm) {
		this.jqElm = jqElm;
		this.ready = false;
		this.queuedMessages = [];
	}
	Applet.prototype.init = function(options) {
		var $this=this;
		this.options = {
			//width : '100%',
			//height : 450,
			mode : "splash",
			maxWidth: 1000,
			ratio: 1,
			baseURL: "http://embed.jocly.net",
			masked: false,
		}
		if (options)
			$.extend(this.options, options);
		var iframeUrl = this.options.baseURL+"/jocly/plazza/embed";
		if(this.options.game)
			iframeUrl+="/"+this.options.game;
		iframeUrl+="?mode=" + this.options.mode;
		this.iframeId = iframeIdRef++;
		this.options.jei = this.iframeId;
		this.listener=function(event) {
			if(event.origin!=$this.options.baseURL || event.data.jei!=$this.iframeId)
				return;
			$this.messageListener(event.data);
		}
		window.addEventListener("message",this.listener,false);
		var iframeName = "jocly-iframe-" + this.iframeId;
		this.iframe = $("<iframe/>").attr("name", iframeName).attr(
				"frameborder", 0).attr("src", "about:blank");
		this.content = this.jqElm.html();
		this.jqElm.empty();

		var canvas=$("<canvas/>").attr("width",this.options.maxWidth).attr("height",this.options.maxWidth*this.options.ratio);
		var image=new Image();
		image.src = canvas[0].toDataURL("image/png");

		this.wrapper=$("<div/>").css({
			position: "relative",
			"white-space": "nowrap",
		}).appendTo(this.jqElm);

		this.wrapper.append($(image).css({
			width: "auto",
			height: "auto",
			"max-width": "100%",
			"max-height": "100%",
			"vertical-align": "bottom",
		}));

		this.container=$("<div/>").css("padding-top",this.options.ratio*100+"%").appendTo(
			$("<div/>").css({
				position: "absolute",
				top: 0,
				bottom: 0,
				left: 0,
				right: 0,
			}).appendTo(this.wrapper)
		);

		this.iframe.attr("width","100%").attr("height","100%").css({
			position: "absolute",
			top: 0,
			right: 0,
			bottom: 0,
			left: 0,
			"white-space": "normal",
		}).appendTo(this.container);

		this.maskElm=$("<div/>").css({
			display: this.options.masked?"block":"none",
			position: "absolute",
			top: 0,
			right: 0,
			width: "100%",
			height: "100%",
			'background-color': 'rgba(0,0,0,.8)',
			"z-index": 1,
		}).appendTo(this.wrapper);

		var initForm = $("<form/>").attr("action", iframeUrl).attr("method",
				"post").attr("target", iframeName);
		$("<input/>").attr("type", "hidden").attr("name", "data").attr("value",
				JSON.stringify(this.options)).appendTo(initForm);
		initForm.appendTo($("body"));
		initForm[0].submit();
		initForm.remove();
	}
	Applet.prototype.remove = function() {
		window.removeEventListener("message",this.listener,false);
		this.jqElm.empty();
		this.jqElm.html(this.content);
		this.jqElm.data("jocly-applet", null);
	}
	Applet.prototype.update = function(options) {
		this.remove();
		this.init(options);
	}
	Applet.prototype.messageListener = function(message) {
		var callback;
		console.log("jocly-applet received message from iframe",message);
		switch(message.type) {
		case 'ready':
			this.ready=true;
			this.queuedMessages.forEach(function(message) {
				this.sendMessage(message);
			},this);
			this.queuedMessages=[];
			break;
		case 'display':
			if(message.initial || message.moves) {
				var crc=$.joclyCRC32(message.initial || '');
				if(message.moves)
					message.moves.forEach(function(move) {
						crc=$.joclyCRC32(move.str,crc);
					});
				$(".jocly-listener").trigger('jocly',{
					type: 'display',
					crc: crc,
				});
			} else
				$(".jocly-listener").trigger('jocly',{
					type: 'undisplay',
				});
			break;
		case 'snapshot':
			callback=this.snapshotCallbacks[message.snapshotId];
			delete this.snapshotCallbacks[message.snapshotId];
			if(message.image) {
				var image=new Image();
				image.onload=function() {
					console.log("image",image.width,"x",image.height)
					callback(image);
				}
				image.src=message.image;
			} else
				callback(null);
			break;
		case 'camera':
			callback=this.cameraCallbacks[message.cameraId];
			delete this.cameraCallbacks[message.cameraId];
			callback(message.camera);
			break;
		default:
			$(".jocly-listener").trigger('jocly',message);
		}
	}
	Applet.prototype.sendMessage = function(message) {
		if(this.ready)
			this.iframe[0].contentWindow.postMessage(message,this.options.baseURL);
		else
			this.queuedMessages.push(message);
	}
	Applet.prototype.view = function(gameName,spec) {
		this.sendMessage({
			type: "view",
			gameName: gameName,
			data: spec,
		});
	}
	Applet.prototype.localPlay = function(gameName,spec) {
		this.sendMessage({
			type: "localPlay",
			gameName: gameName,
			data: spec || {},
		});
	}
	Applet.prototype.setFeatures = function(features) {
		this.sendMessage({
			type: "features",
			features: features,
		});
	}
	Applet.prototype.getId = function() {
		return this.iframeId;
	}
	Applet.prototype.emptyBoard = function(gameName) {
		this.sendMessage({
			type: "emptyBoard",
			gameName: gameName,
		});
	}
	Applet.prototype.viewOptions = function(options) {
		this.sendMessage({
			type: "viewOptions",
			options: options,
		});
	}
	Applet.prototype.mask = function(masked) {
		if(masked)
			this.maskElm.show();
		else
			this.maskElm.hide();
	}
	Applet.prototype.updateCamera = function(camera,delay) {
		this.sendMessage({
			type: "updateCamera",
			camera: camera,
			delay: delay,
		});
	}
	Applet.prototype.snapshotCallbacks={};
	Applet.prototype.snapshot = function(callback) {
		var snapshotId=1;
		while(snapshotId in this.snapshotCallbacks)
			snapshotId++;
		this.snapshotCallbacks[snapshotId]=callback;
		this.sendMessage({
			type: "snapshot",
			snapshotId: snapshotId,
		});
	}
	Applet.prototype.cameraCallbacks={};
	Applet.prototype.getCamera = function(callback) {
		var cameraId=1;
		while(cameraId in this.cameraCallbacks)
			cameraId++;
		this.cameraCallbacks[cameraId]=callback;
		this.sendMessage({
			type: "getCamera",
			cameraId: cameraId,
		});
	}

	$.fn.jocly = function() {
		var $arguments = arguments;
		var retVal = this;
		this.each(function() {
			var applet = $(this).data("jocly-applet");
			var justCreated=false;
			if (!applet) {
				applet = new Applet($(this));
				justCreated=true;
				var options = $arguments[0] || null;
				var dataAttr = $(this).attr("data-jocly");
				if (dataAttr)
					try {
						options = eval("(" + dataAttr + ")"); // jshint ignore:line
					} catch (e) {
						console
								.error("Jocly applet: invalid data-jocly "
										+ dataAttr);
					}
				applet.init(options);
				$(this).data("jocly-applet", applet);
			}
			if ($arguments.length > 0) {
				var method = $arguments[0];
				if(justCreated && typeof method == "object")
					return;
				if (typeof method != "string")
					throw new Error(
							"Jocly applet: first argument must be a string specifying the method to be called");
				if (typeof applet[method] != "function")
					throw new Error("Jocly applet: no such method '"
							+ method + "'");
				var retVal0 = applet[method].apply(applet, Array.prototype.splice
						.call($arguments, 1));
				if(retVal0 !== undefined)
					console.log("method",method,"returns",retVal0)
			}
		});
		return retVal;
	};

	$(document).ready(function() {

		$("[data-jocly]").each(function() {
			var $this=$(this);
			$this.jocly();
			if(this.hasAttribute("data-jocly-init")) {
				var attr=$this.attr("data-jocly-init");
				if(attr.length===0)
					return;
				try {
					var arr=JSON.parse(attr);
					try {
						if(!Array.isArray(arr)) {
							console.warn("jquery.jocly: data-jocly-init attribute is not an array");
						}
						for(var i=0;i<arr.length;i++) {
							var element=arr[i];
							if(Array.isArray(element))
								$this.jocly.apply($this,element);
							else {
								$this.jocly.apply($this,arr);
								return;
							}
						}
					} catch(e) {
						console.warn("jquery.jocly: data-jocly-init error:",e);
					}
				} catch(e) {
					console.warn("jquery.jocly: data-jocly-init attribute has no JSON valid value");
				}
			}
		});

	});

}(jQuery));

<|endoftext|>


<commit_before>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    aws: grunt.file.readJSON('grunt-aws.json'), // for S3

    stylus: {
      compile: {
        options: {
          paths: ['styl'], // folder, where files to be imported are located
          urlfunc: 'url', // use embedurl('test.png') in our code to trigger Data URI embedding
          'include css': true
        },
        files: {
          '../resources/public/css/app.css': 'styl/app.styl' // 1:1 compile
        }
      }
    },

    s3: {
      key: '<%= aws.key %>',
      secret: '<%= aws.secret %>',
      bucket: '<%= aws.bucket %>',
      access: 'public-read',
      encodePaths: true,
      //debug: true,

      // Files to be uploaded.
      upload: [
        {
          src: '../resources/public/index.html',
          dest: 'index.html',
          gzip: true
        },
        {
          src: '../resources/public/sitemap/index.html',
          dest: 'sitemap/index.html',
          gzip: true
        },
        {
          src: '../resources/public/translate/index.html',
          dest: 'translate/index.html',
          gzip: true
        },
        {
          src: '../resources/public/rsa-signer/index.html',
          dest: 'rsa-signer/index.html',
          gzip: true
        },
        {
          src: '../resources/public/mangopay/index.html',
          dest: 'mangopay/index.html',
          gzip: true
        },
        {
          src: '../resources/public/pygmenter/index.html',
          dest: 'pygmenter/index.html',
          gzip: true
        },
        {
          src: '../resources/public/lein-sitemap/index.html',
          dest: 'lein-sitemap/index.html',
          gzip: true
        },
        {
          src: '../resources/public/lein-ping/index.html',
          dest: 'lein-ping/index.html',
          gzip: true
        },
        {
          src: '../resources/public/hashids/index.html',
          dest: 'hashids/index.html',
          gzip: true
        },
        {
          src: '../resources/public/css/app.css',
          dest: 'css/app.css',
          gzip: true
        },
        {
          src: '../resources/public/images/*.png',
          dest: 'images/',
          rel: '../resources/public/images'
        },
        {
          src: '../resources/public/google235235bcbf7ddb0d.html',
          dest: 'google235235bcbf7ddb0d.html'
        },
        {
          src: '../resources/public/robots.txt',
          dest: 'robots.txt'
        },
        {
          src: '../resources/public/humans.txt',
          dest: 'humans.txt'
        },
        {
          src: '../resources/public/sitemap.xml',
          dest: 'sitemap.xml'
        },
        {
          src: '../resources/public/favicon.ico',
          dest: 'favicon.ico'
        }
      ]
    },

    concat: {
      options: {
        separator: ';'
      },
      vendor: {
        src: [
              'js/jquery.js',
              'js/foundation.min.js',
              'js/foundation.topbar.js',
              'js/foundation.offcanvas.js'
              ],
        dest: '../resources/public/js/vendor.js'
      },
    },

    uglify: {
      vendor: {
        files: {
          '../resources/public/js/vendor.js': ['../resources/public/js/vendor.js']
        }
      }
    },
    watch: {
      src: {
        files: ['styl/*.styl'],
        tasks: ['build']
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-stylus');
  grunt.loadNpmTasks('grunt-s3');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('build', ['stylus:compile', 'concat:vendor']);
  grunt.registerTask('deploy', ['stylus:compile', 'concat:vendor', 'uglify:vendor', 's3:upload']);

};
<commit_msg>add mithing file to deploy<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    aws: grunt.file.readJSON('grunt-aws.json'), // for S3

    stylus: {
      compile: {
        options: {
          paths: ['styl'], // folder, where files to be imported are located
          urlfunc: 'url', // use embedurl('test.png') in our code to trigger Data URI embedding
          'include css': true
        },
        files: {
          '../resources/public/css/app.css': 'styl/app.styl' // 1:1 compile
        }
      }
    },

    s3: {
      key: '<%= aws.key %>',
      secret: '<%= aws.secret %>',
      bucket: '<%= aws.bucket %>',
      access: 'public-read',
      encodePaths: true,
      //debug: true,

      // Files to be uploaded.
      upload: [
        {
          src: '../resources/public/index.html',
          dest: 'index.html',
          gzip: true
        },
        {
          src: '../resources/public/sitemap/index.html',
          dest: 'sitemap/index.html',
          gzip: true
        },
        {
          src: '../resources/public/translate/index.html',
          dest: 'translate/index.html',
          gzip: true
        },
        {
          src: '../resources/public/rsa-signer/index.html',
          dest: 'rsa-signer/index.html',
          gzip: true
        },
        {
          src: '../resources/public/mangopay/index.html',
          dest: 'mangopay/index.html',
          gzip: true
        },
        {
          src: '../resources/public/pygmenter/index.html',
          dest: 'pygmenter/index.html',
          gzip: true
        },
        {
          src: '../resources/public/lein-sitemap/index.html',
          dest: 'lein-sitemap/index.html',
          gzip: true
        },
        {
          src: '../resources/public/lein-ping/index.html',
          dest: 'lein-ping/index.html',
          gzip: true
        },
        {
          src: '../resources/public/hashids/index.html',
          dest: 'hashids/index.html',
          gzip: true
        },
        {
          src: '../resources/public/css/app.css',
          dest: 'css/app.css',
          gzip: true
        },
        {
          src: '../resources/public/js/vendor.css',
          dest: 'js/vendor.js',
          gzip: true
        },
        {
          src: '../resources/public/images/*.png',
          dest: 'images/',
          rel: '../resources/public/images'
        },
        {
          src: '../resources/public/google235235bcbf7ddb0d.html',
          dest: 'google235235bcbf7ddb0d.html'
        },
        {
          src: '../resources/public/robots.txt',
          dest: 'robots.txt'
        },
        {
          src: '../resources/public/humans.txt',
          dest: 'humans.txt'
        },
        {
          src: '../resources/public/sitemap.xml',
          dest: 'sitemap.xml'
        },
        {
          src: '../resources/public/favicon.ico',
          dest: 'favicon.ico'
        }
      ]
    },

    concat: {
      options: {
        separator: ';'
      },
      vendor: {
        src: [
              'js/jquery.js',
              'js/foundation.min.js',
              'js/foundation.topbar.js',
              'js/foundation.offcanvas.js'
              ],
        dest: '../resources/public/js/vendor.js'
      },
    },

    uglify: {
      vendor: {
        files: {
          '../resources/public/js/vendor.js': ['../resources/public/js/vendor.js']
        }
      }
    },
    watch: {
      src: {
        files: ['styl/*.styl'],
        tasks: ['build']
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-stylus');
  grunt.loadNpmTasks('grunt-s3');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('build', ['stylus:compile', 'concat:vendor']);
  grunt.registerTask('deploy', ['stylus:compile', 'concat:vendor', 'uglify:vendor', 's3:upload']);

};
<|endoftext|>


<commit_before>require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`,
})

module.exports = {
  siteMetadata: {
    title: 'I AM MATTHIAS',
    description: 'A personal portfolio project',
    siteUrl: 'https://iammatthias.com',
    menuLinks: [
      {
        name: 'Home',
        slug: '/',
      },
      {
        name: 'Photography',
        slug: '/photography/',
      },
      {
        name: 'Blog',
        slug: '/blog/',
      },
      {
        name: 'About',
        slug: '/about/',
      },
    ],
    postsPerFirstPage: 6,
    postsPerPage: 6,
    basePath: '/',
  },
  plugins: [
    'gatsby-plugin-emotion',
    'gatsby-plugin-theme-ui',

    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-plugin-printer`,
      options: {
        puppeteerLaunchOptions: {
          headless: true,
        },
      },
    },
    {
      resolve: `gatsby-plugin-google-fonts`,
      options: {
        fonts: [`Montserrat:400,900`, `Crimson Text`, `Inconsolata`],
        display: 'swap',
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-prismjs`,
          },
          `gatsby-remark-emojis`,
          `gatsby-remark-autolink-headers`,
          {
            resolve: `gatsby-remark-images-contentful`,
            options: {
              maxWidth: 650,
              backgroundColor: 'white',
              linkImagesToOriginal: false,
            },
          },
        ],
      },
    },
    `gatsby-plugin-catch-links`,
    {
      resolve: 'gatsby-source-contentful',
      options: {
        spaceId: process.env.SPACE_ID,
        accessToken: process.env.ACCESS_TOKEN,
        host: process.env.HOST,
      },
    },
    {
      resolve: `gatsby-plugin-segment-js`,
      options: {
        prodKey: process.env.SEGMENT,
        trackPage: true,
      },
    },
    'gatsby-plugin-sitemap',
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        name: 'I AM MATTIAS',
        short_name: 'IAM',
        start_url: '/',
        background_color: '#140D00',
        theme_color: '#140D00',
        display: 'minimal-ui',
        icon: './static/images/favicon.png',
      },
    },
    'gatsby-plugin-offline',
    {
      resolve: `gatsby-plugin-schema-snapshot`,
      options: {
        path: `./src/gatsby/schema/schema.gql`,
        update: process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT,
      },
    },
    'gatsby-plugin-netlify',
  ],
}
<commit_msg>[ skip ci]<commit_after>require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`,
})

module.exports = {
  siteMetadata: {
    title: 'I AM MATTHIAS',
    description: 'A personal portfolio project',
    siteUrl: 'https://iammatthias.com',
    menuLinks: [
      {
        name: 'Home',
        slug: '/',
      },
      {
        name: 'Photography',
        slug: '/photography/',
      },
      {
        name: 'Blog',
        slug: '/blog/',
      },
      {
        name: 'About',
        slug: '/about/',
      },
    ],
    postsPerFirstPage: 6,
    postsPerPage: 6,
    basePath: '/',
  },
  plugins: [
    'gatsby-plugin-emotion',
    'gatsby-plugin-theme-ui',

    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-plugin-printer`,
      options: {
        puppeteerLaunchOptions: {
          headless: true,
        },
      },
    },
    {
      resolve: `gatsby-plugin-google-fonts`,
      options: {
        fonts: [`Montserrat:400,900`, `Crimson Text`, `Inconsolata`],
        display: 'swap',
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-prismjs`,
          },
          `gatsby-remark-emojis`,
          `gatsby-remark-autolink-headers`,
          {
            resolve: `gatsby-remark-images-contentful`,
            options: {
              maxWidth: 650,
              backgroundColor: 'white',
              linkImagesToOriginal: false,
            },
          },
        ],
      },
    },
    `gatsby-plugin-catch-links`,
    {
      resolve: 'gatsby-source-contentful',
      options: {
        spaceId: process.env.CONTENTFUL_SPACE_ID,
        accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
        host: process.env.CONTENTFUL_HOST,
      },
    },
    {
      resolve: `gatsby-plugin-segment-js`,
      options: {
        prodKey: process.env.SEGMENT,
        trackPage: true,
      },
    },
    'gatsby-plugin-sitemap',
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        name: 'I AM MATTIAS',
        short_name: 'IAM',
        start_url: '/',
        background_color: '#140D00',
        theme_color: '#140D00',
        display: 'minimal-ui',
        icon: './static/images/favicon.png',
      },
    },
    'gatsby-plugin-offline',
    {
      resolve: `gatsby-plugin-schema-snapshot`,
      options: {
        path: `./src/gatsby/schema/schema.gql`,
        update: process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT,
      },
    },
    'gatsby-plugin-netlify',
  ],
}
<|endoftext|>


<commit_before>lichess.refreshInsightForm = () => {
  $('form.insight-refresh:not(.armed)')
    .addClass('armed')
    .on('submit', function () {
      fetch(this.action, {
        method: 'post',
        credentials: 'same-origin',
      }).then(lichess.reload);
      $(this).replaceWith($(this).find('.crunching').show());
      return false;
    });
};
lichess.load.then(lichess.refreshInsightForm);
<commit_msg>fix insights refresh spinner<commit_after>lichess.refreshInsightForm = () => {
  $('form.insight-refresh:not(.armed)')
    .addClass('armed')
    .on('submit', function () {
      fetch(this.action, {
        method: 'post',
        credentials: 'same-origin',
      }).then(lichess.reload);
      $(this).replaceWith($(this).find('.crunching').removeClass('none'));
      return false;
    });
};
lichess.load.then(lichess.refreshInsightForm);
<|endoftext|>


<commit_before>var Helper = {
  getURLParameter: function(name) {
    return decodeURI(
      (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
  },

  createPsudoRandomStr: function(stringLength) {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for(var i=0; i < stringLength; i++) {
      text += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    return text;
  },

  requestFullscreen: function(el) {
    if (el.requestFullscreen) {
      el.requestFullscreen();
    } else if (el.mozRequestFullScreen) {
      el.mozRequestFullScreen();
    } else {
      console.warn("Fullscreen is not supported by this device.");
    }
  }
};

var DomHelper = {
  findParentBySelector: function(el, selector) {
    var all = document.querySelectorAll(selector);
    var current = el.parentNode;
    while(current && !this._collectionHas(all, current)) {
      current = current.parentNode; //go up
    }
    return current;
  },

  _collectionHas: function(a, b) {
    for(var i = 0, len = a.length; i < len; i ++) {
      if(a[i] == b) {
        return true;
      }
    }
    return false;
  }

};<commit_msg>Clean up<commit_after>var Helper = {
  getURLParameter: function(aName) {
    return decodeURI(
      (RegExp(aName + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
  },

  createPsudoRandomStr: function(aStringLength) {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for(var i=0; i < aStringLength; i++) {
      text += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    return text;
  },

  requestFullscreen: function(aElem) {
    if (aElem.requestFullscreen) {
      aElem.requestFullscreen();
    } else if (aElem.mozRequestFullScreen) {
      aElem.mozRequestFullScreen();
    } else {
      console.warn("Fullscreen is not supported by this device.");
    }
  }
};

var DomHelper = {
  findParentBySelector: function(aElem, aSelector) {
    var all = document.querySelectorAll(aSelector);
    var current = aElem.parentNode;
    while(current && !this._collectionHas(all, current)) {
      current = current.parentNode; //go up
    }
    return current;
  },

  _collectionHas: function(a, b) {
    for(var i = 0, len = a.length; i < len; i ++) {
      if(a[i] == b) {
        return true;
      }
    }
    return false;
  }

};<|endoftext|>


<commit_before>module.exports = {
  siteMetadata: {
    siteTitle: 'Gatsby Material Starter', // Site title.
    linkPrefix: '/gatsby-material-starter', // Prefixes all links. For cases when deployed to example.github.io/gatsby-material-starter/.
    disqusShortname: 'https-vagr9k-github-io-gatsby-material-starter', // Disqus shortname.
    postDefaultCategoryID: 'Tech', // Default category for posts.
    userName: 'Material User', // Username to display in the author segment.
    userLocation: 'Yerevan, Armenia', // User location to display in the author segment.
    userAvatar: 'https://api.adorable.io/avatars/150/test.png', // User avatar to display in the author segment.
    userDescription: "Yeah, I like animals better than people sometimes... Especially dogs. Dogs are the best. Every time you come home, they act like they haven't seen you in a year. And the good thing about dogs... is they got different dogs for different people.", // User description to display in the author segment.
    // Links to social profiles/projects you want to display in the author segment/navigation bar.
    userLinks: [
      {
        label: 'Website',
        url: '//mywebsite.example.local',
        iconClassName: 'fa fa-link',
      },
      {
        label: 'GitHub',
        url: '//github.com.local/USER',
        iconClassName: 'fa fa-github',
      },
      {
        label: 'Twitter',
        url: '//twitter.local/USER',
        iconClassName: 'fa fa-twitter',
      },
      {
        label: 'Instagram',
        url: '//instagram.local/USER',
        iconClassName: 'fa fa-instagram',
      },
      {
        label: 'Facebook',
        url: '//facebook.com.local/USER',
        iconClassName: 'fa fa-facebook',
      },
      {
        label: 'Enail',
        url: 'mailto:gmail.com.local/USER',
        iconClassName: 'fa fa-envelope',
      },
    ],
    copyright: 'Copyright © 2017. Material User', // Copyright string in the footer of the website.
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-sass',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'pages',
        path: `${__dirname}/src/pages/`,
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 690,
            },
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
          },
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
        ],
      },
    },
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: 'UA-47311644-4',
      },
    },
    'gatsby-plugin-sharp',
    'gatsby-plugin-catch-links',
  ],
};
<commit_msg>Updates siteMetadata with pathPrefix.<commit_after>module.exports = {
  siteMetadata: {
    siteTitle: 'Gatsby Material Starter', // Site title.
    pathPrefix: '/gatsby-material-starter', // Prefixes all links. For cases when deployed to example.github.io/gatsby-material-starter/.
    disqusShortname: 'https-vagr9k-github-io-gatsby-material-starter', // Disqus shortname.
    postDefaultCategoryID: 'Tech', // Default category for posts.
    userName: 'Material User', // Username to display in the author segment.
    userLocation: 'Yerevan, Armenia', // User location to display in the author segment.
    userAvatar: 'https://api.adorable.io/avatars/150/test.png', // User avatar to display in the author segment.
    userDescription: "Yeah, I like animals better than people sometimes... Especially dogs. Dogs are the best. Every time you come home, they act like they haven't seen you in a year. And the good thing about dogs... is they got different dogs for different people.", // User description to display in the author segment.
    // Links to social profiles/projects you want to display in the author segment/navigation bar.
    userLinks: [
      {
        label: 'Website',
        url: '//mywebsite.example.local',
        iconClassName: 'fa fa-link',
      },
      {
        label: 'GitHub',
        url: '//github.com.local/USER',
        iconClassName: 'fa fa-github',
      },
      {
        label: 'Twitter',
        url: '//twitter.local/USER',
        iconClassName: 'fa fa-twitter',
      },
      {
        label: 'Instagram',
        url: '//instagram.local/USER',
        iconClassName: 'fa fa-instagram',
      },
      {
        label: 'Facebook',
        url: '//facebook.com.local/USER',
        iconClassName: 'fa fa-facebook',
      },
      {
        label: 'Enail',
        url: 'mailto:gmail.com.local/USER',
        iconClassName: 'fa fa-envelope',
      },
    ],
    copyright: 'Copyright © 2017. Material User', // Copyright string in the footer of the website.
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-sass',
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'pages',
        path: `${__dirname}/src/pages/`,
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 690,
            },
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
          },
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
        ],
      },
    },
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: 'UA-47311644-4',
      },
    },
    'gatsby-plugin-sharp',
    'gatsby-plugin-catch-links',
  ],
};
<|endoftext|>


<commit_before>define(function(require) {
    'use strict';

    var _ = require('underscore'),
        str = require('js/app-config').string,
        config = require('js/app-config').config,
        InvitationDAO = require('js/dao/invitation-dao'),
        dbType = 'email_OUTBOX';

    var OutboxBO = function(emailDao, invitationDao) {
        this._emailDao = emailDao;
        this._invitationDao = invitationDao;
        this._outboxBusy = false;
    };

    OutboxBO.prototype.startChecking = function(callback) {
        // start periodic checking of outbox
        this._intervalId = setInterval(this._processOutbox.bind(this, callback), config.checkOutboxInterval);
    };

    OutboxBO.prototype.stopChecking = function() {
        if (!this._intervalId) {
            return;
        }

        clearInterval(this._intervalId);
        delete this._intervalId;
    };

    OutboxBO.prototype._processOutbox = function(callback) {
        var self = this,
            emails;

        if (self._outboxBusy) {
            return;
        }

        checkStorage();

        function checkStorage() {
            self._outboxBusy = true;

            // get last item from outbox
            self._emailDao._devicestorage.listItems(dbType, 0, null, function(err, pending) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                // update outbox folder count
                emails = pending;

                // sending pending mails
                processMails();
            });
        }

        function processMails() {
            // in the navigation controller, this updates the folder count

            if (emails.length === 0) {
                self._outboxBusy = false;
                callback(null, 0);
                return;
            }

            callback(null, emails.length);
            var email = emails.shift();
            checkReceivers(email);
        }

        function checkReceivers(email) {
            var unregisteredUsers, receiverChecked;

            unregisteredUsers = [];
            receiverChecked = _.after(email.to.length, function() {
                if (unregisteredUsers.length > 0) {
                    invite(unregisteredUsers);
                    return;
                }

                sendEncrypted(email);
            });

            email.to.forEach(function(recipient) {
                self._emailDao._keychain.getReceiverPublicKey(recipient.address, function(err, key) {
                    if (err) {
                        // stop processing
                    }

                    if (!key) {
                        unregisteredUsers.push(recipient);
                    }

                    receiverChecked();
                });
            });
        }

        function invite(addresses) {
            var sender = self._emailDao._account.emailAddress;

            var invitationFinished = _.after(addresses.length, function() {
                // after all of the invitations are checked and sent (if necessary),
                //
                processMails();
            });

            // send invite
            addresses.forEach(function(recipient) {
                var recipientAddress = recipient.address;
                self._invitationDao.check({
                    recipient: recipientAddress,
                    sender: sender
                }, function(err, status) {
                    if (status === InvitationDAO.INVITE_PENDING) {
                        // the recipient is already invited, we're done here.
                        invitationFinished();
                        return;
                    }

                    // the recipient is not yet invited, so let's do that
                    self._invitationDao.invite({
                        recipient: recipientAddress,
                        sender: sender
                    }, function(err, status) {
                        if (err) {
                            console.error(err.errMsg);
                            return;
                        }
                        if (status !== InvitationDAO.INVITE_SUCCESS) {
                            console.error('could not successfully invite ' + recipientAddress);
                            return;
                        }

                        sendInvitationMail(recipient, sender);
                    });

                });
            });

            function sendInvitationMail(recipient, sender) {
                var to = (recipient.name || recipient.address).split('@')[0].split('.')[0].split(' ')[0],
                    invitationMail = {
                        from: [sender],
                        to: [recipient],
                        subject: str.invitationSubject,
                        body: 'Hi ' + to + ',\n\n' + str.invitationMessage + '\n\n\n' + str.signature
                    };

                // send invitation mail
                self._emailDao.send(invitationMail, function(err) {
                    if (err) {
                        console.error(err.errMsg);
                    }
                    invitationFinished();
                });
            }
        }

        function sendEncrypted(email) {
            self._emailDao.encryptedSend(email, function(err) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                removeFromStorage(email.id);
            });
        }

        function removeFromStorage(id) {
            if (!id) {
                self._outboxBusy = false;
                callback({
                    errMsg: 'Cannot remove email from storage without a valid id!'
                });
                return;
            }

            // delete email from local storage
            var key = dbType + '_' + id;
            self._emailDao._devicestorage.removeList(key, function(err) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                processMails();
            });
        }
    };

    return OutboxBO;
});<commit_msg>add documentation<commit_after>define(function(require) {
    'use strict';

    var _ = require('underscore'),
        str = require('js/app-config').string,
        config = require('js/app-config').config,
        InvitationDAO = require('js/dao/invitation-dao'),
        dbType = 'email_OUTBOX';

    /**
     * High level business object that orchestrates the local outbox.
     * The local outbox takes care of the emails before they are being sent.
     * It also checks periodically if there are any mails in the local device storage to be sent.
     */
    var OutboxBO = function(emailDao, invitationDao) {
        this._emailDao = emailDao;
        this._invitationDao = invitationDao;
        this._outboxBusy = false;
    };

    /**
     * This function activates the periodic checking of the local device storage for pending mails.
     * @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails.
     */
    OutboxBO.prototype.startChecking = function(callback) {
        // start periodic checking of outbox
        this._intervalId = setInterval(this._processOutbox.bind(this, callback), config.checkOutboxInterval);
    };

    /**
     * Outbox stops the periodic checking of the local device storage for pending mails.
     */
    OutboxBO.prototype.stopChecking = function() {
        if (!this._intervalId) {
            return;
        }

        clearInterval(this._intervalId);
        delete this._intervalId;
    };

    /**
     * Checks the local device storage for pending mails.
     * @param {Function} callback(error, pendingMailsCount) Callback that informs you about the count of pending mails.
     */
    OutboxBO.prototype._processOutbox = function(callback) {
        var self = this,
            emails;

        if (self._outboxBusy) {
            return;
        }

        checkStorage();

        function checkStorage() {
            self._outboxBusy = true;

            // get last item from outbox
            self._emailDao._devicestorage.listItems(dbType, 0, null, function(err, pending) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                // update outbox folder count
                emails = pending;

                // sending pending mails
                processMails();
            });
        }

        function processMails() {
            // in the navigation controller, this updates the folder count

            if (emails.length === 0) {
                self._outboxBusy = false;
                callback(null, 0);
                return;
            }

            callback(null, emails.length);
            var email = emails.shift();
            checkReceivers(email);
        }

        function checkReceivers(email) {
            var unregisteredUsers, receiverChecked;

            unregisteredUsers = [];
            receiverChecked = _.after(email.to.length, function() {
                if (unregisteredUsers.length > 0) {
                    invite(unregisteredUsers);
                    return;
                }

                sendEncrypted(email);
            });

            email.to.forEach(function(recipient) {
                self._emailDao._keychain.getReceiverPublicKey(recipient.address, function(err, key) {
                    if (err) {
                        // stop processing
                    }

                    if (!key) {
                        unregisteredUsers.push(recipient);
                    }

                    receiverChecked();
                });
            });
        }

        function invite(addresses) {
            var sender = self._emailDao._account.emailAddress;

            var invitationFinished = _.after(addresses.length, function() {
                // after all of the invitations are checked and sent (if necessary),
                //
                processMails();
            });

            // send invite
            addresses.forEach(function(recipient) {
                var recipientAddress = recipient.address;
                self._invitationDao.check({
                    recipient: recipientAddress,
                    sender: sender
                }, function(err, status) {
                    if (status === InvitationDAO.INVITE_PENDING) {
                        // the recipient is already invited, we're done here.
                        invitationFinished();
                        return;
                    }

                    // the recipient is not yet invited, so let's do that
                    self._invitationDao.invite({
                        recipient: recipientAddress,
                        sender: sender
                    }, function(err, status) {
                        if (err) {
                            console.error(err.errMsg);
                            return;
                        }
                        if (status !== InvitationDAO.INVITE_SUCCESS) {
                            console.error('could not successfully invite ' + recipientAddress);
                            return;
                        }

                        sendInvitationMail(recipient, sender);
                    });

                });
            });

            function sendInvitationMail(recipient, sender) {
                var to = (recipient.name || recipient.address).split('@')[0].split('.')[0].split(' ')[0],
                    invitationMail = {
                        from: [sender],
                        to: [recipient],
                        subject: str.invitationSubject,
                        body: 'Hi ' + to + ',\n\n' + str.invitationMessage + '\n\n\n' + str.signature
                    };

                // send invitation mail
                self._emailDao.send(invitationMail, function(err) {
                    if (err) {
                        console.error(err.errMsg);
                    }
                    invitationFinished();
                });
            }
        }

        function sendEncrypted(email) {
            self._emailDao.encryptedSend(email, function(err) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                removeFromStorage(email.id);
            });
        }

        function removeFromStorage(id) {
            if (!id) {
                self._outboxBusy = false;
                callback({
                    errMsg: 'Cannot remove email from storage without a valid id!'
                });
                return;
            }

            // delete email from local storage
            var key = dbType + '_' + id;
            self._emailDao._devicestorage.removeList(key, function(err) {
                if (err) {
                    self._outboxBusy = false;
                    callback(err);
                    return;
                }

                processMails();
            });
        }
    };

    return OutboxBO;
});<|endoftext|>


<commit_before>var app = angular.module("ethics-app");

// PUT
app.controller("DocConfirmController", function($scope, $routeParams, $location, $docService, $window) {

    // API
    $scope.loadData = function() {
        $docService.get($routeParams.doc_id).success(function(response) {
            console.log("Check confirm get");
            $scope.doc = response;
        });
        // Call pdf generation function
        $docService.pdf($routeParams.doc_id).success(function(response) {
          console.log("Check confirm pdf");
          $scope.icf_eng = angular.copy($scope.doc._id + "_eng.pdf");
          $scope.icf_ger = angular.copy($scope.doc._id + "_ger.pdf");
        });

    };

    // INIT
    $scope.loadData();
    $scope.validateEthics = function() {
      return false
    };

});
<commit_msg>bugfix<commit_after>var app = angular.module("ethics-app");

// PUT
app.controller("DocConfirmController", function($scope, $routeParams, $location, $docService, $window) {

    // API
    $scope.loadData = function() {
        $docService.get($routeParams.doc_id).success(function(response) {
            console.log("Check confirm get");
            $scope.doc = response;
            $scope.icf_eng = angular.copy($scope.doc._id + "_eng.pdf");
            $scope.icf_ger = angular.copy($scope.doc._id + "_ger.pdf");
        });
        // Call pdf generation function
        $docService.pdf($routeParams.doc_id).success(function(response) {
          console.log("Check confirm pdf");
        });

    };

    // INIT
    $scope.loadData();
    $scope.validateEthics = function() {
      return false
    };

});
<|endoftext|>


<commit_before>'use strict';
(function() {
    requirejs.config({
        baseUrl: 'src/classes',

        paths: {
            'three'         : '../../lib/three',
            'OrbitControls' : '../../lib/OrbitControls',
            'stats'         : '../../lib/stats.min',
            'config'        : '../config',

            'enums/Constants'               : '../enums/Constants',
            'enums/AstronomicalObjectType'  : '../enums/AstronomicalObjectType',
            'enums/NoiseType'  : '../enums/NoiseType'
        },

        shim: {
            'three': {
                exports: 'THREE'
            },

            'OrbitControls': {
                deps: ['three'],
                exports: 'OrbitControls'
            },

            'stats': {
                exports: 'Stats'
            }
        }
    });

    require(['../axiom']);
})();<commit_msg>Removed unused bootstrap.js<commit_after><|endoftext|>


<commit_before>import Modal from './modal'
import Browser from './browser'

export function addWrapper (htmlData, params) {
  const bodyStyle = 'font-family:' + params.font + ' !important; font-size: ' + params.font_size + ' !important; width:100%;'
  return '
' + htmlData + '
'
}

export function capitalizePrint (obj) {
  return obj.charAt(0).toUpperCase() + obj.slice(1)
}

export function collectStyles (element, params) {
  const win = document.defaultView || window

  // String variable to hold styling for each element
  let elementStyle = ''

  // Loop over computed styles
  const styles = win.getComputedStyle(element, '')

  for (let key = 0; key < styles.length; key++)  {
    // Check if style should be processed
    if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
      if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';'
    }
  }

  // Print friendly defaults (deprecated)
  elementStyle += 'max-width: ' + params.maxWidth + 'px !important;' + params.font_size + ' !important;'

  return elementStyle
}

function targetStylesMatch (styles, value) {
  for (let i = 0; i < styles.length; i++) {
    if (typeof value === 'object' && value.indexOf(styles[i]) !== -1) return true
  }
  return false
}

export function addHeader (printElement, params) {
  // Create the header container div
  const headerContainer = document.createElement('div')

  // Check if the header is text or raw html
  if (isRawHTML(params.header)) {
    headerContainer.innerHTML = params.header
  } else {
    // Create header element
    const headerElement = document.createElement('h1')

    // Create header text node
    const headerNode = document.createTextNode(params.header)

    // Build and style
    headerElement.appendChild(headerNode)
    headerElement.setAttribute('style', params.headerStyle)
    headerContainer.appendChild(headerElement)
  }

  printElement.insertBefore(headerContainer, printElement.childNodes[0])
}

export function cleanUp (params) {
  // If we are showing a feedback message to user, remove it
  if (params.showModal) Modal.close()

  // Check for a finished loading hook function
  if (params.onLoadingEnd) params.onLoadingEnd()

  // If preloading pdf files, clean blob url
  if (params.showModal || params.onLoadingStart) window.URL.revokeObjectURL(params.printable)

  // If a onPrintDialogClose callback is given, execute it
  if (params.onPrintDialogClose) {
    let event = 'mouseover'

    if (Browser.isChrome() || Browser.isFirefox()) {
      // Ps.: Firefox will require an extra click in the document to fire the focus event.
      event = 'focus'
    }
    const handler = () => {
      // Make sure the event only happens once.
      window.removeEventListener(event, handler)

      params.onPrintDialogClose()
    }

    window.addEventListener(event, handler)
  }
}

export function isRawHTML (raw) {
  const regexHtml = new RegExp('<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>(.*?)</\\1>')
  return regexHtml.test(raw)
}
<commit_msg>Fix code style<commit_after>import Modal from './modal'
import Browser from './browser'

export function addWrapper (htmlData, params) {
  const bodyStyle = 'font-family:' + params.font + ' !important; font-size: ' + params.font_size + ' !important; width:100%;'
  return '
' + htmlData + '
'
}

export function capitalizePrint (obj) {
  return obj.charAt(0).toUpperCase() + obj.slice(1)
}

export function collectStyles (element, params) {
  const win = document.defaultView || window

  // String variable to hold styling for each element
  let elementStyle = ''

  // Loop over computed styles
  const styles = win.getComputedStyle(element, '')

  for (let key = 0; key < styles.length; key++) {
    // Check if style should be processed
    if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
      if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';'
    }
  }

  // Print friendly defaults (deprecated)
  elementStyle += 'max-width: ' + params.maxWidth + 'px !important;' + params.font_size + ' !important;'

  return elementStyle
}

function targetStylesMatch (styles, value) {
  for (let i = 0; i < styles.length; i++) {
    if (typeof value === 'object' && value.indexOf(styles[i]) !== -1) return true
  }
  return false
}

export function addHeader (printElement, params) {
  // Create the header container div
  const headerContainer = document.createElement('div')

  // Check if the header is text or raw html
  if (isRawHTML(params.header)) {
    headerContainer.innerHTML = params.header
  } else {
    // Create header element
    const headerElement = document.createElement('h1')

    // Create header text node
    const headerNode = document.createTextNode(params.header)

    // Build and style
    headerElement.appendChild(headerNode)
    headerElement.setAttribute('style', params.headerStyle)
    headerContainer.appendChild(headerElement)
  }

  printElement.insertBefore(headerContainer, printElement.childNodes[0])
}

export function cleanUp (params) {
  // If we are showing a feedback message to user, remove it
  if (params.showModal) Modal.close()

  // Check for a finished loading hook function
  if (params.onLoadingEnd) params.onLoadingEnd()

  // If preloading pdf files, clean blob url
  if (params.showModal || params.onLoadingStart) window.URL.revokeObjectURL(params.printable)

  // If a onPrintDialogClose callback is given, execute it
  if (params.onPrintDialogClose) {
    let event = 'mouseover'

    if (Browser.isChrome() || Browser.isFirefox()) {
      // Ps.: Firefox will require an extra click in the document to fire the focus event.
      event = 'focus'
    }
    const handler = () => {
      // Make sure the event only happens once.
      window.removeEventListener(event, handler)

      params.onPrintDialogClose()
    }

    window.addEventListener(event, handler)
  }
}

export function isRawHTML (raw) {
  const regexHtml = new RegExp('<([A-Za-z][A-Za-z0-9]*)\\b[^>]*>(.*?)</\\1>')
  return regexHtml.test(raw)
}
<|endoftext|>


<commit_before>var SIDE_MENU_TEMPLATE = 'sideMenuTemplate';
var mapVM = require('./MapViewModel.js').getMapViewModel();

var sideMenuViewModel;

var SideMenuViewModel = function() {
  this.types = new can.Observe({conf: true,
                                                conv: true,
                                                ent: true,
                                                fair: true,
                                                food: true,
                                                fund: true,
                                                meet: true,
                                                music: true,
                                                perf: true,
                                                rec: true,
                                                relig: true,
                                                reun: true,
                                                sales: true,
                                                semi: true,
                                                soci: true,
                                                sports: true,
                                                trade: true,
                                                travel: true,
                                                other: true});
  this.dateFromDom = $('#dateFrom');
  this.dateToDom = $('#dateTo');

  mapVM.types = this.types;

  $('#sideMenu').html(can.view(SIDE_MENU_TEMPLATE, mapVM));
  var self = this;

  this.types.bind('change', function(event, attr, how, newVal, oldVal) {
    self.prop.attr('types', (this.conf ? '1' : '0') +
                                      (this.conv ? '1' : '0') +
                                      (this.ent ? '1' : '0') +
                                      (this.fair ? '1' : '0') +
                                      (this.food ? '1' : '0') +
                                      (this.fund ? '1' : '0') +
                                      (this.meet ? '1' : '0') +
                                      (this.music? '1' : '0') +
                                      (this.perf ? '1' : '0') +
                                      (this.rec ? '1' : '0') +
                                      (this.relig ? '1' : '0') +
                                      (this.reun ? '1' : '0') +
                                      (this.sales ? '1' : '0') +
                                      (this.semi ? '1' : '0') +
                                      (this.soci ? '1' : '0') +
                                      (this.sports ? '1' : '0') +
                                      (this.trade ? '1' : '0') +
                                      (this.travel ? '1' : '0') +
                                      (this.other ? '1' : '0'));
  });

  this.dateFromDom.datepicker({
    defaultDate : mapVM.prop.dateFrom,
    changeMonth : true,
    changeYear : true,
    numberOfMonths : 1,
    onSelect : function(selectedDate) {
      this.dateToDom.datepicker('option', 'minDate', selectedDate);
      $(this).trigger('change');
    },
    maxDate: mapVM.prop.dateTo
  });

  this.dateToDom.datepicker({
    defaultDate : mapVM.prop.dateFrom,
    changeMonth : true,
    changeYear : true,
    numberOfMonths : 1,
    onSelect : function(selectedDate) {
      this.dateFromDom.datepicker('option', 'maxDate', selectedDate);
      $(this).trigger('change');
    },
    minDate: mapVM.prop.dateFrom
  });

  $('#loadMyLocation').popover();
  $('#sideMenu').mCustomScrollbar({
    advanced:{
        autoScrollOnFocus: false
    }
  });
};

module.exports.getSideMenuViewModel = function() {
  if(!sideMenuViewModel) {
    sideMenuViewModel = new SideMenuViewModel();
  }
  return sideMenuViewModel;
};

SideMenuViewModel.prototype.setDateToSelectedEvent = function(startDate, endDate) {
  mapVM.prop.attr('dateFrom', startDate);
  mapVM.prop.attr('dateTo', endDate);
  this.dateFromDom.datepicker('option', 'maxDate', endDate);
  this.dateToDom.datepicker('option', 'minDate', startDate);
};
<commit_msg>Removing a retarded line.<commit_after>var SIDE_MENU_TEMPLATE = 'sideMenuTemplate';
var mapVM = require('./MapViewModel.js').getMapViewModel();

var sideMenuViewModel;

var SideMenuViewModel = function() {
  this.types = new can.Observe({conf: true,
                                                conv: true,
                                                ent: true,
                                                fair: true,
                                                food: true,
                                                fund: true,
                                                meet: true,
                                                music: true,
                                                perf: true,
                                                rec: true,
                                                relig: true,
                                                reun: true,
                                                sales: true,
                                                semi: true,
                                                soci: true,
                                                sports: true,
                                                trade: true,
                                                travel: true,
                                                other: true});
  this.dateFromDom = $('#dateFrom');
  this.dateToDom = $('#dateTo');

  $('#sideMenu').html(can.view(SIDE_MENU_TEMPLATE, mapVM));
  var self = this;

  this.types.bind('change', function(event, attr, how, newVal, oldVal) {
    self.prop.attr('types', (this.conf ? '1' : '0') +
                                      (this.conv ? '1' : '0') +
                                      (this.ent ? '1' : '0') +
                                      (this.fair ? '1' : '0') +
                                      (this.food ? '1' : '0') +
                                      (this.fund ? '1' : '0') +
                                      (this.meet ? '1' : '0') +
                                      (this.music? '1' : '0') +
                                      (this.perf ? '1' : '0') +
                                      (this.rec ? '1' : '0') +
                                      (this.relig ? '1' : '0') +
                                      (this.reun ? '1' : '0') +
                                      (this.sales ? '1' : '0') +
                                      (this.semi ? '1' : '0') +
                                      (this.soci ? '1' : '0') +
                                      (this.sports ? '1' : '0') +
                                      (this.trade ? '1' : '0') +
                                      (this.travel ? '1' : '0') +
                                      (this.other ? '1' : '0'));
  });

  this.dateFromDom.datepicker({
    defaultDate : mapVM.prop.dateFrom,
    changeMonth : true,
    changeYear : true,
    numberOfMonths : 1,
    onSelect : function(selectedDate) {
      this.dateToDom.datepicker('option', 'minDate', selectedDate);
      $(this).trigger('change');
    },
    maxDate: mapVM.prop.dateTo
  });

  this.dateToDom.datepicker({
    defaultDate : mapVM.prop.dateFrom,
    changeMonth : true,
    changeYear : true,
    numberOfMonths : 1,
    onSelect : function(selectedDate) {
      this.dateFromDom.datepicker('option', 'maxDate', selectedDate);
      $(this).trigger('change');
    },
    minDate: mapVM.prop.dateFrom
  });

  $('#loadMyLocation').popover();
  $('#sideMenu').mCustomScrollbar({
    advanced:{
        autoScrollOnFocus: false
    }
  });
};

module.exports.getSideMenuViewModel = function() {
  if(!sideMenuViewModel) {
    sideMenuViewModel = new SideMenuViewModel();
  }
  return sideMenuViewModel;
};

SideMenuViewModel.prototype.setDateToSelectedEvent = function(startDate, endDate) {
  mapVM.prop.attr('dateFrom', startDate);
  mapVM.prop.attr('dateTo', endDate);
  this.dateFromDom.datepicker('option', 'maxDate', endDate);
  this.dateToDom.datepicker('option', 'minDate', startDate);
};
<|endoftext|>


<commit_before>$('form').find('[name=username]').blur(function (e) {
  e.preventDefault();

  var ajax = $.ajax({
    url: "http://zenifytheweb.com/api/examples/check_username",
    method: 'post',
    data: { username: $(this).val() }
  });

  ajax.done(function(result) {
    console.log(result);
  });

  ajax.error(function(error) {
    console.log(error);
  });
});<commit_msg>add l17 examples<commit_after>$('form').find('[name=username]').blur(function (e) {
  e.preventDefault();

  var ajax = $.ajax({
    url: "http://zenifytheweb.com/api/examples/check_username",
    method: 'get',
    data: { username: $(this).val() }
  });

  ajax.done(function(result) {
    console.log(result);
  });

  ajax.error(function(error) {
    console.log(error);
  });
});<|endoftext|>