Hugo go go go
Made a hugo setup from scratch to generate a static blog and portfolio webpage. The old stuff may still be found in static/old.
This commit is contained in:
18
static/old/it1/js/auth.js
Normal file
18
static/old/it1/js/auth.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
var signin = function() {
|
||||
firebase.auth()
|
||||
.signInWithEmailAndPassword($('#mail')[0].value, $('#password')[0].value)
|
||||
.then(function() {
|
||||
document.location.href = "/it1/"
|
||||
}).catch(function(error) {
|
||||
$('#status').html('<h3>Kunne ikke logge inn som '+$('#mail')[0].value+'!</h3><p>'+error.code+': '+error.message+'</p>')
|
||||
$('#status').css('color', 'red')
|
||||
})
|
||||
}
|
||||
|
||||
$(document).keydown(function(e) {
|
||||
if (e.which == 13){
|
||||
$("#login").click()
|
||||
}
|
||||
})
|
||||
|
52
static/old/it1/js/converters/bok.js
Normal file
52
static/old/it1/js/converters/bok.js
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
class Book {
|
||||
constructor(title, author, publisher, rating, published, id=0) {
|
||||
this.cfid = id
|
||||
this.title = title
|
||||
this.author = author
|
||||
this.publisher = publisher
|
||||
this.rating = rating
|
||||
this.published = published
|
||||
}
|
||||
toString() {
|
||||
return this.title+' av '+this.author+', terningkast '+this.rating+', utgitt '+this.published.toString().slice(0,15)+', forlag; '+this.publisher
|
||||
}
|
||||
toHtml(elm) {
|
||||
let span = function(selector, string, p, color='red') {
|
||||
$($(selector)[$(selector).length-1]).append('<span style="color: '+color+'"></span>')
|
||||
$($(selector+' > span')[$(selector+' > span').length-1]).text(string)
|
||||
$($(selector)[$(selector).length-1]).append(p)
|
||||
}
|
||||
elm.append('<p class="book"></p>')
|
||||
span('.book', this.title, ' av ')
|
||||
span('.book', this.author, ', terningkast ')
|
||||
span('.book', this.rating, ', utgitt ')
|
||||
span('.book', this.published.toString().slice(0,15), ', forlag: ', 'green')
|
||||
span('.book', this.publisher, firebase.auth().currentUser?' <a class="btn btn-primary" href="javascript: remove(\''+this.cfid+'\')">Slett</a>':'', 'yellow')
|
||||
}
|
||||
}
|
||||
|
||||
bookConverter = {
|
||||
toFirestore: function(book) {
|
||||
let millis = Date.parse(book.published)
|
||||
return {
|
||||
tittel: book.title,
|
||||
forfatter: book.author,
|
||||
forlag: book.publisher,
|
||||
terningkast: book.rating,
|
||||
utgitt: new firebase.firestore.Timestamp(millis/1000, 0)
|
||||
}
|
||||
},
|
||||
fromFirestore: function(snapshot, options) {
|
||||
const data = snapshot.data(options)
|
||||
return new Book(
|
||||
data.tittel,
|
||||
data.forfatter,
|
||||
data.forlag,
|
||||
data.terningkast,
|
||||
data.utgitt.toDate(),
|
||||
snapshot.id
|
||||
)
|
||||
}
|
||||
}
|
||||
|
34
static/old/it1/js/converters/kommentar.js
Normal file
34
static/old/it1/js/converters/kommentar.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
class Comment {
|
||||
constructor(name, message, id=0) {
|
||||
this.name = name,
|
||||
this.message = message,
|
||||
this.cfid = id
|
||||
}
|
||||
toString() {
|
||||
return this.name+': '+this.message
|
||||
}
|
||||
toHtml(elm) {
|
||||
elm.append('<p class="kommentar"></p>')
|
||||
$($('.kommentar')[$('.kommentar').length-1]).text(this.toString())
|
||||
firebase.auth().currentUser?$($('.kommentar')[$('.kommentar').length-1]).append(' <a class="btn btn-primary" href="javascript: remove(\''+this.cfid+'\')">Slett</a>'):undefined
|
||||
}
|
||||
}
|
||||
|
||||
commentConverter = {
|
||||
toFirestore: function(comment) {
|
||||
return {
|
||||
navn: comment.name,
|
||||
melding: comment.message
|
||||
}
|
||||
},
|
||||
fromFirestore: function(snapshot, options) {
|
||||
const data = snapshot.data(options)
|
||||
return new Comment(
|
||||
data.navn,
|
||||
data.melding,
|
||||
snapshot.id
|
||||
)
|
||||
}
|
||||
}
|
||||
|
10
static/old/it1/js/init-firebase.js
Normal file
10
static/old/it1/js/init-firebase.js
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
firebase.initializeApp({
|
||||
apiKey: "AIzaSyAhU3F-De17VAsUgpRjj25f48QiXycorD4",
|
||||
authDomain: "it1-heimdal-vgs.firebaseapp.com",
|
||||
databaseURL: "https://it1-heimdal-vgs.firebaseio.com",
|
||||
projectId: "it1-heimdal-vgs",
|
||||
storageBucket: "it1-heimdal-vgs.appspot.com",
|
||||
messagingSenderId: "206703382262",
|
||||
appId: "1:206703382262:web:be48f32d11a15fa28f26d7"
|
||||
})
|
43
static/old/it1/js/navbar.js
Normal file
43
static/old/it1/js/navbar.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
$('#navbar').parent().html(`
|
||||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark" id="navbar">
|
||||
<a class="navbar-brand" href="/it1/">IT1 firebase stuff</a>
|
||||
<!-- <ul class="navbar-nav">
|
||||
<li class="nav-item right">
|
||||
<a class="nav-link" href="/it1/about.html">About</a>
|
||||
</li>
|
||||
</ul> -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<!-- <li class="nav-item right" id="register-btn">
|
||||
<a class="nav-link" href="/register">Register</a>
|
||||
</li> -->
|
||||
<li class="nav-item right">
|
||||
<a class="nav-link" id="login-btn" href="/it1/bruker/"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>`)
|
||||
|
||||
var signout = function() {
|
||||
firebase.auth()
|
||||
.signOut()
|
||||
.then(function() {
|
||||
document.location.href = '/it1/'
|
||||
}).catch(function(error) {
|
||||
alert('could not log out: '+error.message)
|
||||
})
|
||||
}
|
||||
|
||||
firebase.auth().onAuthStateChanged(function(user) {
|
||||
if (user) {
|
||||
$('#login-btn').attr('href', 'javascript: signout()')
|
||||
$('#login-btn').html('Logout')
|
||||
} else {
|
||||
$('#login-btn').attr('href', '/it1/bruker/')
|
||||
$('#login-btn').html('Login')
|
||||
}
|
||||
})
|
||||
|
||||
for (var i = 0; i < $('#navbar').children().length; i++) {
|
||||
$('#navbar').children().css('color', 'springgreen')
|
||||
}
|
||||
|
Reference in New Issue
Block a user