Skip to content

Instantly share code, notes, and snippets.

@yooouuri
Created April 12, 2018 19:30
Show Gist options
  • Select an option

  • Save yooouuri/976084ae4f0904d2ae69a6b79a1168c7 to your computer and use it in GitHub Desktop.

Select an option

Save yooouuri/976084ae4f0904d2ae69a6b79a1168c7 to your computer and use it in GitHub Desktop.
webpackJsonp([0], {
"+VGo": function(t, e) {},
0: function(t, e, a) {
t.exports = a("NHnr")
},
"1/oy": function(t, e) {},
"6HqF": function(t, e) {},
"9M+g": function(t, e) {},
D50l: function(t, e) {},
Id91: function(t, e) {},
Jmt5: function(t, e) {},
NHnr: function(t, e, a) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var o = a("/5sW"),
n = function() {
var t = this,
e = t.$createElement,
a = t._self._c || e;
return a("div", {
attrs: {
id: "app"
}
}, [a("router-view")], 1)
},
s = [],
r = a("XyMi");
function l(t) {
a("+VGo")
}
var i = null,
c = !1,
u = l,
m = null,
f = null,
d = Object(r["a"])(i, n, s, c, u, m, f),
b = d.exports,
p = a("/ocq"),
h = {
data: function() {
return {
tweets: [],
text: "",
show: !0
}
},
created: function() {
this.fetchData()
},
watch: {
$route: "fetchData"
},
methods: {
onSubmit: function(t) {
var e = this;
t.preventDefault();
var a = localStorage.getItem("token"),
o = "user_id=1&text=" + this.text;
fetch("http://localhost:8080/Kwetter-1.0-SNAPSHOT/api/tweets", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer ".concat(a)
},
body: o
}).then(function(t) {
return t.json()
}).then(function(t) {
e.tweets.unshift(t)
})
},
onReset: function(t) {
var e = this;
t.preventDefault(), this.text = "", this.show = !1, this.$nextTick(function() {
e.show = !0
})
},
fetchData: function() {
var t = this;
fetch("http://localhost:8080/Kwetter-1.0-SNAPSHOT/api/users/1/tweets").then(function(t) {
return t.json()
}).then(function(e) {
t.tweets = e
})
}
}
},
v = function() {
var t = this,
e = t.$createElement,
a = t._self._c || e;
return a("b-container", {
attrs: {
fluid: ""
}
}, [a("b-row", [a("b-col", [t._v("1 of 3")]), a("b-col", {
attrs: {
cols: "8"
}
}, [t.show ? a("b-form", {
staticClass: "my-5",
on: {
submit: t.onSubmit,
reset: t.onReset
}
}, [a("b-form-textarea", {
attrs: {
id: "textarea1",
placeholder: "What’s happening?",
rows: 3,
"max-rows": 6
},
model: {
value: t.text,
callback: function(e) {
t.text = e
},
expression: "text"
}
}), a("p", {
staticClass: "text-right mt-2"
}, [a("b-button", {
attrs: {
type: "submit"
}
}, [t._v("Tweet")])], 1)], 1) : t._e(), t._l(t.tweets, function(e) {
return a("b-card", {
key: e.id,
staticClass: "mb-2",
attrs: {
data: e
}
}, [a("b-img", {
staticClass: "rounded-circle",
attrs: {
left: "",
src: e.profile_image,
width: "125",
height: "125"
}
}), a("p", {
staticClass: "card-text font-weight-bold"
}, [t._v("\n @" + t._s(e.username) + "\n ")]), a("p", {
staticClass: "card-text"
}, [t._v("\n " + t._s(e.text) + "\n ")]), a("p", {
staticClass: "card-text font-weight-bold"
}, [t._v("\n " + t._s(e.date) + "\n ")])], 1)
})], 2), a("b-col", [t._v("3 of 3")])], 1)], 1)
},
w = [],
g = !1,
_ = null,
x = null,
C = null,
y = Object(r["a"])(h, v, w, g, _, x, C),
k = y.exports,
S = {
name: "Profile",
data: function() {
return {
tweets: [],
followers: [],
following: [],
user: {},
fields: ["username"]
}
},
created: function() {
this.fetchData()
},
watch: {
$route: "fetchData"
},
methods: {
fetchData: function() {
var t = this,
e = localStorage.getItem("token");
fetch("http://localhost:8080/Kwetter-1.0-SNAPSHOT/api/users/me", {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer ".concat(e)
}
}).then(function(t) {
return t.json()
}).then(function(e) {
t.user = {
username: e.username,
bio: e.bio,
image: e.image,
website: e.website
}, t.tweets = e.tweets || [], t.following = e.following || [], t.followers = e.followers || []
})
}
}
},
P = function() {
var t = this,
e = t.$createElement,
a = t._self._c || e;
return a("div", [a("b-container", [a("b-row", [a("b-col", {
attrs: {
cols: "4"
}
}, [a("b-card", {
staticClass: "my-4",
attrs: {
title: t.user.username,
"img-src": t.user.image
}
}, [a("p", {
staticClass: "card-text"
}, [t._v(t._s(t.user.bio))]), a("p", {
staticClass: "card-text"
}, [a("a", {
attrs: {
href: t.user.website
}
}, [t._v(t._s(t.user.website))])]), a("b-row", [a("b-col", [a("span", {
staticClass: "small"
}, [t._v(t._s(t.tweets.length))])]), a("b-col", [a("span", {
staticClass: "small"
}, [a("b-link", {
directives: [{
name: "b-modal",
rawName: "v-b-modal.following",
modifiers: {
following: !0
}
}]
}, [t._v(t._s(t.following.length))])], 1)]), a("b-col", [a("span", {
staticClass: "small"
}, [a("b-link", {
directives: [{
name: "b-modal",
rawName: "v-b-modal.followers",
modifiers: {
followers: !0
}
}]
}, [t._v(t._s(t.followers.length))])], 1)])], 1), a("b-row", [a("b-col", [a("span", {
staticClass: "small"
}, [t._v("Tweets")])]), a("b-col", [a("span", {
staticClass: "small"
}, [a("b-link", {
directives: [{
name: "b-modal",
rawName: "v-b-modal.following",
modifiers: {
following: !0
}
}]
}, [t._v("Following")])], 1)]), a("b-col", [a("span", {
staticClass: "small"
}, [a("b-link", {
directives: [{
name: "b-modal",
rawName: "v-b-modal.followers",
modifiers: {
followers: !0
}
}]
}, [t._v("Followers")])], 1)])], 1)], 1)], 1), a("b-col", {
attrs: {
cols: "8"
}
}, t._l(t.tweets, function(e) {
return a("b-card", {
key: e.id,
staticClass: "my-4"
}, [a("b-img", {
staticClass: "rounded-circle",
attrs: {
left: "",
src: e.profile_image,
width: "125",
height: "125"
}
}), a("p", {
staticClass: "card-text font-weight-bold"
}, [t._v("\n @" + t._s(e.username) + "\n ")]), a("p", {
staticClass: "card-text"
}, [t._v("\n " + t._s(e.text) + "\n ")]), a("p", {
staticClass: "card-text font-weight-bold"
}, [t._v("\n " + t._s(e.date) + "\n ")])], 1)
}))], 1)], 1), a("b-modal", {
attrs: {
"hide-footer": "",
id: "following",
title: "Following"
}
}, t._l(t.following, function(e) {
return a("table", [a("tbody", [a("tr", [a("td", [t._v("@" + t._s(e.username))])])])])
})), a("b-modal", {
attrs: {
"hide-footer": "",
id: "followers",
title: "Followers"
}
}, t._l(t.followers, function(e) {
return a("table", [a("tbody", [a("tr", [a("td", [t._v("@" + t._s(e.username))])])])])
}))], 1)
},
T = [];
function j(t) {
a("6HqF")
}
var N = !1,
O = j,
D = "data-v-543150bb",
E = null,
$ = Object(r["a"])(S, P, T, N, O, D, E),
H = $.exports,
I = {
name: "Login",
data: function() {
return {
email: "",
password: ""
}
},
methods: {
login: function(t) {
var e = this;
t.preventDefault();
var a = "email=".concat(this.email, "&password=").concat(this.password);
fetch("http://localhost:8080/Kwetter-1.0-SNAPSHOT/api/users/login", {
method: "POST",
body: a,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(function(t) {
return t.json()
}).then(function(t) {
localStorage.setItem("token", t.bearer), e.$router.push("/")
})
}
}
},
A = function() {
var t = this,
e = t.$createElement,
a = t._self._c || e;
return a("b-form", {
staticClass: "form-signin",
on: {
submit: t.login
}
}, [a("h1", {
staticClass: "h3 mb-3 font-weight-normal"
}, [t._v("Please sign in")]), a("label", {
staticClass: "sr-only",
attrs: {
for: "inputEmail"
}
}, [t._v("Email address")]), a("input", {
directives: [{
name: "model",
rawName: "v-model",
value: t.email,
expression: "email"
}],
staticClass: "form-control",
attrs: {
type: "email",
id: "inputEmail",
placeholder: "Email address",
required: "",
autofocus: ""
},
domProps: {
value: t.email
},
on: {
input: function(e) {
e.target.composing || (t.email = e.target.value)
}
}
}), a("label", {
staticClass: "sr-only",
attrs: {
for: "inputPassword"
}
}, [t._v("Password")]), a("input", {
directives: [{
name: "model",
rawName: "v-model",
value: t.password,
expression: "password"
}],
staticClass: "form-control",
attrs: {
type: "password",
id: "inputPassword",
placeholder: "Password",
required: ""
},
domProps: {
value: t.password
},
on: {
input: function(e) {
e.target.composing || (t.password = e.target.value)
}
}
}), a("div", {
staticClass: "checkbox mb-3"
}, [a("label", [a("input", {
attrs: {
type: "checkbox",
value: "remember-me"
}
}), t._v(" Remember me\n ")])]), a("button", {
staticClass: "btn btn-lg btn-primary btn-block",
attrs: {
type: "submit"
}
}, [t._v("Sign in")]), a("p", {
staticClass: "mt-5 mb-3 text-muted"
}, [t._v("© 2017-2018")])])
},
F = [];
function M(t) {
a("rMjo")
}
var q = !1,
K = M,
z = "data-v-c6629f8c",
J = null,
L = Object(r["a"])(I, A, F, q, K, z, J),
R = L.exports,
B = {
name: "LoggedIn",
methods: {
logout: function() {
localStorage.removeItem("token"), this.$router.push("/login")
}
}
},
G = function() {
var t = this,
e = t.$createElement,
a = t._self._c || e;
return a("div", [a("b-navbar", {
attrs: {
toggleable: "",
type: "light",
variant: "light"
}
}, [a("b-navbar-toggle", {
attrs: {
target: "nav_text_collapse"
}
}), a("b-navbar-brand", [t._v("Kwetter")]), a("b-collapse", {
attrs: {
"is-nav": "",
id: "nav_text_collapse"
}
}, [a("b-navbar-nav", [a("b-nav-item", {
attrs: {
to: {
path: "/"
}
}
}, [t._v("Timeline")]), a("b-nav-item", {
attrs: {
to: {
path: "/profile"
}
}
}, [t._v("Profile")])], 1), a("b-navbar-nav", {
staticClass: "ml-auto"
}, [a("b-navbar-nav", {
attrs: {
right: ""
}
}, [a("b-nav-item", {
on: {
click: t.logout
}
}, [t._v("Logout")])], 1)], 1)], 1)], 1), a("router-view")], 1)
},
V = [];
function W(t) {
a("D50l")
}
var Q = !1,
X = W,
U = "data-v-4eee7893",
Y = null,
Z = Object(r["a"])(B, G, V, Q, X, U, Y),
tt = Z.exports;
o["a"].use(p["a"]);
var et = new p["a"]({
routes: [{
path: "/login",
name: "login",
component: R
}, {
path: "/",
component: tt,
children: [{
path: "/",
name: "home",
component: k,
beforeEnter: function(t, e, a) {
null === localStorage.getItem("token") && a("/login"), a()
}
}, {
path: "/profile",
name: "profile",
component: H,
beforeEnter: function(t, e, a) {
null === localStorage.getItem("token") && a("/login"), a()
}
}]
}]
}),
at = a("e6fC");
a("Jmt5"), a("9M+g");
o["a"].config.productionTip = !1, o["a"].use(at["a"]), new o["a"]({
router: et,
render: function(t) {
return t(b)
}
}).$mount("#app")
},
rMjo: function(t, e) {},
zj2Q: function(t, e) {}
}, [0]);
//# sourceMappingURL=app.0bb933a0.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment