forked from thathoff/kirby-git-content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 14.1 KB
/
index.js
1
(function(){"use strict";var x={};function C(){return x}function y(e){"@babel/helpers - typeof";return y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(e)}function h(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function u(e){h(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||y(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console<"u"&&(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 p(e,t){h(2,arguments);var n=u(e),a=u(t),i=n.getTime()-a.getTime();return i<0?-1:i>0?1:i}function W(e,t){h(2,arguments);var n=u(e),a=u(t),i=n.getFullYear()-a.getFullYear(),s=n.getMonth()-a.getMonth();return i*12+s}function F(e){h(1,arguments);var t=u(e);return t.setHours(23,59,59,999),t}function O(e){h(1,arguments);var t=u(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function N(e){h(1,arguments);var t=u(e);return F(t).getTime()===O(t).getTime()}function I(e,t){h(2,arguments);var n=u(e),a=u(t),i=p(n,a),s=Math.abs(W(n,a)),r;if(s<1)r=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*s);var l=p(n,a)===-i;N(u(e))&&s===1&&p(e,a)===1&&(l=!1),r=i*(s-Number(l))}return r===0?0:r}function R(e,t){return h(2,arguments),u(e).getTime()-u(t).getTime()}var k={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},A="trunc";function X(e){return e?k[e]:k[A]}function j(e,t,n){h(2,arguments);var a=R(e,t)/1e3;return X(void 0)(a)}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"}},$=function(t,n,a){var i,s=Y[t];return typeof s=="string"?i=s:n===1?i=s.one:i=s.other.replace("{{count}}",n.toString()),a!=null&&a.addSuffix?a.comparison&&a.comparison>0?"in "+i:i+" ago":i};function M(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,a=e.formats[n]||e.formats[e.defaultWidth];return a}}var E={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},z={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},B={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},V={date:M({formats:E,defaultWidth:"full"}),time:M({formats:z,defaultWidth:"full"}),dateTime:M({formats:B,defaultWidth:"full"})},q={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},L=function(t,n,a,i){return q[t]};function g(e){return function(t,n){var a=n!=null&&n.context?String(n.context):"standalone",i;if(a==="formatting"&&e.formattingValues){var s=e.defaultFormattingWidth||e.defaultWidth,r=n!=null&&n.width?String(n.width):s;i=e.formattingValues[r]||e.formattingValues[s]}else{var l=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[l]}var d=e.argumentCallback?e.argumentCallback(t):t;return i[d]}}var H={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},J={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},U={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"]},Q={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"]},G={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"}},K={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"}},Z=function(t,n){var a=Number(t),i=a%100;if(i>20||i<10)switch(i%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},tt={ordinalNumber:Z,era:g({values:H,defaultWidth:"wide"}),quarter:g({values:J,defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:g({values:U,defaultWidth:"wide"}),day:g({values:Q,defaultWidth:"wide"}),dayPeriod:g({values:G,defaultWidth:"wide",formattingValues:K,defaultFormattingWidth:"wide"})};function b(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.width,i=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;var r=s[0],l=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],o=Array.isArray(l)?nt(l,function(f){return f.test(r)}):et(l,function(f){return f.test(r)}),d;d=e.valueCallback?e.valueCallback(o):o,d=n.valueCallback?n.valueCallback(d):d;var m=t.slice(r.length);return{value:d,rest:m}}}function et(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function nt(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function at(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.match(e.matchPattern);if(!a)return null;var i=a[0],s=t.match(e.parsePattern);if(!s)return null;var r=e.valueCallback?e.valueCallback(s[0]):s[0];r=n.valueCallback?n.valueCallback(r):r;var l=t.slice(i.length);return{value:r,rest:l}}}var rt=/^(\d+)(th|st|nd|rd)?/i,it=/\d+/i,ot={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},st={any:[/^b/i,/^(a|c)/i]},ut={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},lt={any:[/1/i,/2/i,/3/i,/4/i]},ct={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},dt={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]},ht={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},ft={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]},mt={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},vt={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}},gt={ordinalNumber:at({matchPattern:rt,parsePattern:it,valueCallback:function(t){return parseInt(t,10)}}),era:b({matchPatterns:ot,defaultMatchWidth:"wide",parsePatterns:st,defaultParseWidth:"any"}),quarter:b({matchPatterns:ut,defaultMatchWidth:"wide",parsePatterns:lt,defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:b({matchPatterns:ct,defaultMatchWidth:"wide",parsePatterns:dt,defaultParseWidth:"any"}),day:b({matchPatterns:ht,defaultMatchWidth:"wide",parsePatterns:ft,defaultParseWidth:"any"}),dayPeriod:b({matchPatterns:mt,defaultMatchWidth:"any",parsePatterns:vt,defaultParseWidth:"any"})},bt={code:"en-US",formatDistance:$,formatLong:V,formatRelative:L,localize:tt,match:gt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function S(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function pt(e){return S({},e)}function P(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}var _=1440,yt=2520,w=43200,Mt=86400;function wt(e,t,n){var a,i;h(2,arguments);var s=C(),r=(a=(i=n==null?void 0:n.locale)!==null&&i!==void 0?i:s.locale)!==null&&a!==void 0?a:bt;if(!r.formatDistance)throw new RangeError("locale must contain formatDistance property");var l=p(e,t);if(isNaN(l))throw new RangeError("Invalid time value");var o=S(pt(n),{addSuffix:!!(n!=null&&n.addSuffix),comparison:l}),d,m;l>0?(d=u(t),m=u(e)):(d=u(e),m=u(t));var f=j(m,d),xt=(P(m)-P(d))/1e3,c=Math.round((f-xt)/60),v;if(c<2)return n!=null&&n.includeSeconds?f<5?r.formatDistance("lessThanXSeconds",5,o):f<10?r.formatDistance("lessThanXSeconds",10,o):f<20?r.formatDistance("lessThanXSeconds",20,o):f<40?r.formatDistance("halfAMinute",0,o):f<60?r.formatDistance("lessThanXMinutes",1,o):r.formatDistance("xMinutes",1,o):c===0?r.formatDistance("lessThanXMinutes",1,o):r.formatDistance("xMinutes",c,o);if(c<45)return r.formatDistance("xMinutes",c,o);if(c<90)return r.formatDistance("aboutXHours",1,o);if(c<_){var Ct=Math.round(c/60);return r.formatDistance("aboutXHours",Ct,o)}else{if(c<yt)return r.formatDistance("xDays",1,o);if(c<w){var Wt=Math.round(c/_);return r.formatDistance("xDays",Wt,o)}else if(c<Mt)return v=Math.round(c/w),r.formatDistance("aboutXMonths",v,o)}if(v=I(m,d),v<12){var Ft=Math.round(c/w);return r.formatDistance("xMonths",Ft,o)}else{var T=v%12,D=Math.floor(v/12);return T<3?r.formatDistance("aboutXYears",D,o):T<9?r.formatDistance("overXYears",D,o):r.formatDistance("almostXYears",D+1,o)}}function Dt(e,t,n,a,i,s,r,l){var o=typeof e=="function"?e.options:e;return t&&(o.render=t,o.staticRenderFns=n,o._compiled=!0),{exports:e,options:o}}const kt={name:"GitContent",props:{status:{type:Object},log:{type:Array,default:[]},branch:{type:String,default:""},disableBranchManagement:{type:Boolean,default:!1},helpText:{}},computed:{commitItems(){const e=[];return this.log.forEach(t=>{e.push({text:t.message,info:this.formatRelative(t.date)+" / "+t.author+" / "+t.hash.substr(0,7),link:!1})}),e},statusItems(){const e=[];return this.status.files.forEach(t=>{e.push({text:t.filename,info:t.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()},revert:async function(){this.$dialog("git-content/revert")},commit:async function(){this.$dialog("git-content/commit")},switchBranch:async function(){this.$dialog("git-content/branch")},createBranch:async function(){this.$dialog("git-content/create-branch")},formatRelative(e){return wt(new Date(e),new Date,{addSuffix:!0})}}};var St=function(){var t=this,n=t._self._c;return n("k-inside",[n("k-view",{staticClass:"k-git-content-view"},[n("k-header",[t._v("Git Content "+t._s(t.size))]),t.helpText?n("section",{staticClass:"k-section"},[n("k-box",{attrs:{text:t.helpText,html:"true",theme:"info"}})],1):t._e(),t.status.files.length?n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Uncommitted changes")]),n("k-button-group",{attrs:{buttons:[{text:"Revert Changes",icon:"undo",click:t.revert},{text:"Commit Changes",icon:"check",click:t.commit}]}})],1),n("k-collection",{attrs:{items:t.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):t._e(),n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Remote synchronization")]),n("k-button-group",{attrs:{buttons:[{text:"Pull",icon:"download",click:t.pull},{text:"Push",icon:"upload",click:t.push}]}})],1),n("k-box",{attrs:{text:t.remoteStatus.text,theme:t.remoteStatus.theme}})],1),n("section",{staticClass:"k-section"},[n("header",{staticClass:"k-section-header"},[n("k-headline",[t._v("Latest "+t._s(t.log.length)+" changes on branch »"+t._s(t.branch)+"«")]),t.disableBranchManagement?t._e():n("k-button-group",{attrs:{buttons:[{text:"Create Branch",icon:"add",click:t.createBranch},{text:"Switch Branch",icon:"refresh",click:t.switchBranch}]}})],1),n("k-collection",{attrs:{items:t.commitItems}})],1)],1)],1)},Pt=[],_t=Dt(kt,St,Pt);const Tt=_t.exports;panel.plugin("thathoff/git-content",{components:{"git-content":Tt}})})();