forked from thathoff/kirby-git-content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 13.9 KB
/
index.js
1
(function(){"use strict";var W={};function O(){return W}function m(e,a){if(a.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+a.length+" present")}function l(e){m(1,arguments);var a=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&a==="[object Date]"?new Date(e.getTime()):typeof e=="number"||a==="[object Number]"?new Date(e):((typeof e=="string"||a==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function M(e,a){m(2,arguments);var t=l(e),n=l(a),o=t.getTime()-n.getTime();return o<0?-1:o>0?1:o}function F(e,a){m(2,arguments);var t=l(e),n=l(a),o=t.getFullYear()-n.getFullYear(),u=t.getMonth()-n.getMonth();return o*12+u}function N(e){m(1,arguments);var a=l(e);return a.setHours(23,59,59,999),a}function R(e){m(1,arguments);var a=l(e),t=a.getMonth();return a.setFullYear(a.getFullYear(),t+1,0),a.setHours(23,59,59,999),a}function x(e){m(1,arguments);var a=l(e);return N(a).getTime()===R(a).getTime()}function A(e,a){m(2,arguments);var t=l(e),n=l(a),o=M(t,n),u=Math.abs(F(t,n)),r;if(u<1)r=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-o*u);var d=M(t,n)===-o;x(l(e))&&u===1&&M(e,n)===1&&(d=!1),r=o*(u-Number(d))}return r===0?0:r}function $(e,a){return m(2,arguments),l(e).getTime()-l(a).getTime()}var D={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},I="trunc";function X(e){return e?D[e]:D[I]}function E(e,a,t){m(2,arguments);var n=$(e,a)/1e3;return X(t==null?void 0:t.roundingMethod)(n)}var Y={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},j=function(e,a,t){var n,o=Y[e];return typeof o=="string"?n=o:a===1?n=o.one:n=o.other.replace("{{count}}",a.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n},z=j;function y(e){return function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=a.width?String(a.width):e.defaultWidth,n=e.formats[t]||e.formats[e.defaultWidth];return n}}var V={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},L={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},q={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},U={date:y({formats:V,defaultWidth:"full"}),time:y({formats:L,defaultWidth:"full"}),dateTime:y({formats:q,defaultWidth:"full"})},H=U,J={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Q=function(e,a,t,n){return J[e]},G=Q;function b(e){return function(a,t){var n=t!=null&&t.context?String(t.context):"standalone",o;if(n==="formatting"&&e.formattingValues){var u=e.defaultFormattingWidth||e.defaultWidth,r=t!=null&&t.width?String(t.width):u;o=e.formattingValues[r]||e.formattingValues[u]}else{var d=e.defaultWidth,i=t!=null&&t.width?String(t.width):e.defaultWidth;o=e.values[i]||e.values[d]}var s=e.argumentCallback?e.argumentCallback(a):a;return o[s]}}var B={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},K={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Z={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},ee={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},te={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ae={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ne=function(e,a){var t=Number(e),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},re={ordinalNumber:ne,era:b({values:B,defaultWidth:"wide"}),quarter:b({values:K,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:b({values:Z,defaultWidth:"wide"}),day:b({values:ee,defaultWidth:"wide"}),dayPeriod:b({values:te,defaultWidth:"wide",formattingValues:ae,defaultFormattingWidth:"wide"})},ie=re;function p(e){return function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.width,o=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],u=a.match(o);if(!u)return null;var r=u[0],d=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],i=Array.isArray(d)?se(d,function(h){return h.test(r)}):oe(d,function(h){return h.test(r)}),s;s=e.valueCallback?e.valueCallback(i):i,s=t.valueCallback?t.valueCallback(s):s;var v=a.slice(r.length);return{value:s,rest:v}}}function oe(e,a){for(var t in e)if(e.hasOwnProperty(t)&&a(e[t]))return t}function se(e,a){for(var t=0;t<e.length;t++)if(a(e[t]))return t}function ue(e){return function(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.match(e.matchPattern);if(!n)return null;var o=n[0],u=a.match(e.parsePattern);if(!u)return null;var r=e.valueCallback?e.valueCallback(u[0]):u[0];r=t.valueCallback?t.valueCallback(r):r;var d=a.slice(o.length);return{value:r,rest:d}}}var le=/^(\d+)(th|st|nd|rd)?/i,de=/\d+/i,fe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},he={any:[/^b/i,/^(a|c)/i]},ce={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},me={any:[/1/i,/2/i,/3/i,/4/i]},ve={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ge={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},be={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},pe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Me={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ye={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},we={ordinalNumber:ue({matchPattern:le,parsePattern:de,valueCallback:function(e){return parseInt(e,10)}}),era:p({matchPatterns:fe,defaultMatchWidth:"wide",parsePatterns:he,defaultParseWidth:"any"}),quarter:p({matchPatterns:ce,defaultMatchWidth:"wide",parsePatterns:me,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:p({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:ge,defaultParseWidth:"any"}),day:p({matchPatterns:be,defaultMatchWidth:"wide",parsePatterns:pe,defaultParseWidth:"any"}),dayPeriod:p({matchPatterns:Me,defaultMatchWidth:"any",parsePatterns:ye,defaultParseWidth:"any"})},_e=we,De={code:"en-US",formatDistance:z,formatLong:H,formatRelative:G,localize:ie,match:_e,options:{weekStartsOn:0,firstWeekContainsDate:1}},Pe=De;function P(e,a){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t]);return e}function Se(e){return P({},e)}function S(e){var a=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return a.setUTCFullYear(e.getFullYear()),e.getTime()-a.getTime()}var k=1440,ke=2520,w=43200,Te=86400;function Ce(e,a,t){var n,o;m(2,arguments);var u=O(),r=(n=(o=t==null?void 0:t.locale)!==null&&o!==void 0?o:u.locale)!==null&&n!==void 0?n:Pe;if(!r.formatDistance)throw new RangeError("locale must contain formatDistance property");var d=M(e,a);if(isNaN(d))throw new RangeError("Invalid time value");var i=P(Se(t),{addSuffix:Boolean(t==null?void 0:t.addSuffix),comparison:d}),s,v;d>0?(s=l(a),v=l(e)):(s=l(e),v=l(a));var h=E(v,s),c=(S(v)-S(s))/1e3,f=Math.round((h-c)/60),g;if(f<2)return t!=null&&t.includeSeconds?h<5?r.formatDistance("lessThanXSeconds",5,i):h<10?r.formatDistance("lessThanXSeconds",10,i):h<20?r.formatDistance("lessThanXSeconds",20,i):h<40?r.formatDistance("halfAMinute",0,i):h<60?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",1,i):f===0?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",f,i);if(f<45)return r.formatDistance("xMinutes",f,i);if(f<90)return r.formatDistance("aboutXHours",1,i);if(f<k){var $e=Math.round(f/60);return r.formatDistance("aboutXHours",$e,i)}else{if(f<ke)return r.formatDistance("xDays",1,i);if(f<w){var Ie=Math.round(f/k);return r.formatDistance("xDays",Ie,i)}else if(f<Te)return g=Math.round(f/w),r.formatDistance("aboutXMonths",g,i)}if(g=A(v,s),g<12){var Xe=Math.round(f/w);return r.formatDistance("xMonths",Xe,i)}else{var C=g%12,_=Math.floor(g/12);return C<3?r.formatDistance("aboutXYears",_,i):C<9?r.formatDistance("overXYears",_,i):r.formatDistance("almostXYears",_+1,i)}}var We=function(){var e=this,a=e.$createElement,t=e._self._c||a;return t("k-inside",[t("k-view",{staticClass:"k-git-content-view"},[t("k-header",[e._v("Git Content "+e._s(e.size))]),e.status.files.length?t("section",{staticClass:"k-section"},[t("header",{staticClass:"k-section-header"},[t("k-headline",[e._v("Uncommitted changes")])],1),t("k-collection",{attrs:{items:e.statusItems,help:"Refer to the <a target='_blank' href='https://git-scm.com/docs/git-status#_short_format'>Git documentation</a> on how to interpret the status codes to the right."}})],1):e._e(),t("section",{staticClass:"k-section"},[t("header",{staticClass:"k-section-header"},[t("k-headline",[e._v("Remote synchronization")])],1),t("k-box",{attrs:{text:e.remoteStatus.text,theme:e.remoteStatus.theme}})],1),t("section",{staticClass:"k-section"},[t("header",{staticClass:"k-section-header"},[t("k-headline",[e._v("Latest "+e._s(e.log.length)+" changes on branch \xBB"+e._s(e.branch)+"\xAB")]),t("k-button-group",{attrs:{buttons:[{text:"Pull",icon:"download",click:e.pull},{text:"Push",icon:"upload",click:e.push}]}})],1),t("k-collection",{attrs:{items:e.commitItems}})],1)],1)],1)},Oe=[];function Fe(e,a,t,n,o,u,r,d){var i=typeof e=="function"?e.options:e;a&&(i.render=a,i.staticRenderFns=t,i._compiled=!0),n&&(i.functional=!0),u&&(i._scopeId="data-v-"+u);var s;if(r?(s=function(c){c=c||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!c&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(c=__VUE_SSR_CONTEXT__),o&&o.call(this,c),c&&c._registeredComponents&&c._registeredComponents.add(r)},i._ssrRegister=s):o&&(s=d?function(){o.call(this,(i.functional?this.parent:this).$root.$options.shadowRoot)}:o),s)if(i.functional){i._injectStyles=s;var v=i.render;i.render=function(f,g){return s.call(g),v(f,g)}}else{var h=i.beforeCreate;i.beforeCreate=h?[].concat(h,s):[s]}return{exports:e,options:i}}const Ne={name:"GitContent",props:{status:{type:Object},log:{type:Array,default:[]},branch:{type:String,default:""}},computed:{commitItems(){const e=[];return this.log.forEach(a=>{e.push({text:a.message,info:this.formatRelative(a.date)+" / "+a.hash.substr(0,7),link:!1})}),e},statusItems(){const e=[];return this.status.files.forEach(a=>{e.push({text:a.filename,info:a.code,link:!1})}),e},remoteStatus(){if(!this.status.hasRemote)return{text:"No remote branch found.",theme:"negative"};if(this.status.diffFromOrigin===0)return{text:"Your branch is up to date with origin/"+this.branch,theme:"positive"};const e=Math.abs(this.status.diffFromOrigin);return{text:`Your branch is ${this.status.diffFromOrigin>0?"ahead":"behind"} of origin/${this.branch} by ${e} commit${e!==1?"s":""}.`,theme:"notice"}}},methods:{pull:async function(){await panel.app.$api.post("/git-content/pull"),this.$reload()},push:async function(){await panel.app.$api.post("/git-content/push"),this.$reload()},formatRelative(e){return Ce(new Date(e),new Date,{addSuffix:!0})}}},T={};var Re=Fe(Ne,We,Oe,!1,xe,null,null,null);function xe(e){for(let a in T)this[a]=T[a]}var Ae=function(){return Re.exports}();panel.plugin("thathoff/git-content",{components:{"git-content":Ae}})})();