-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cded004
commit b793d78
Showing
21 changed files
with
228 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ router | |
i18n | ||
momentjs | ||
collectionFS | ||
imagemagick |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
Meteor.subscribe('questions'); | ||
Meteor.subscribe('myData'); | ||
Meteor.subscribe('myPictures'); | ||
|
||
//Deps.autorun(function () { | ||
// userProfileHandle = Meteor.subscribe("userProfile", Session.get("currentUserProfile")); | ||
//}); | ||
Deps.autorun(function () { | ||
userProfileHandle = Meteor.subscribe("userProfile", Session.get("currentUserProfile")); | ||
userProfileHandle = Meteor.subscribe("oneUserProfile", Session.get("currentUserProfile")); | ||
userPictureHandle = Meteor.subscribe("oneUserPictures", Session.get("currentUserProfile")); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template name="p404"> | ||
<h1>This is not the page you're looking for</h1> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
Template.profile_picture_edit.events({ | ||
'change input': function(e){ | ||
e.preventDefault(); | ||
_.each(e.srcElement.files, function(file){ | ||
Meteor.uploadPicture(file, file.name, function(err, res){ | ||
if(err){ | ||
console.log(err); | ||
} else { | ||
console.log('weeeeeeeeee', res); | ||
} | ||
}); | ||
}) | ||
var files = e.target.files; | ||
_.each(files, function(file){ | ||
var res = Pictures.storeFile(file, {}); | ||
if(res){ | ||
return res | ||
} else { | ||
throw new Meteor.Error(500, 'Something went wrong'); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template name="profile_pictures"> | ||
{{#each pictures}} | ||
{{#if thumbnail50x50}} | ||
<img src="{{thumbnail50x50}}"> | ||
{{else}} | ||
No Thumbnail available. | ||
{{/if}} | ||
{{else}} | ||
You haven't upload any picture | ||
{{/each}} | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Template.profile_pictures.helpers({ | ||
pictures: function(){ | ||
return Pictures.find({owner: Meteor.userId()}, {sort: {sortorder: -1}}); | ||
}, | ||
original: function(){ | ||
if(this.fileHandler && this.fileHandler.save){ | ||
return this.fileHandler.save.url; | ||
} else { | ||
return null; | ||
} | ||
}, | ||
thumbnail50x50: function(){ | ||
console.log('fileHandler', this.fileHandler); | ||
if(this.fileHandler && this.fileHandler.thumbnail50x50){ | ||
return this.fileHandler.thumbnail50x50.url; | ||
} else { | ||
return null; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Pictures = new CollectionFS('pictures', {autopublish: false}); | ||
|
||
Pictures.allow({ | ||
insert: function(userId, myFile) { | ||
return Pictures.find({owner: userId}).count() < 8 && userId && myFile.owner === userId; | ||
}, | ||
update: function(userId, files, fields, modifier) { | ||
return _.all(files, function (myFile) { | ||
return (userId == myFile.owner); | ||
}); //EO iterate through files | ||
}, | ||
remove: function(userId, files) { return false; } | ||
}); | ||
|
||
var isImage = function(type){ | ||
return type == 'image/jpeg'; | ||
}; | ||
|
||
Pictures.fileHandlers({ | ||
save: function(options){ | ||
console.log('Running fileHandler save'); | ||
if (options.fileRecord.length > 5000000 || !isImage(options.fileRecord.contentType)){ | ||
return null; | ||
} | ||
return { blob: options.blob, fileRecord: options.fileRecord }; | ||
}, | ||
thumbnail50x50: function(options){ | ||
console.log('running thumbnail 50x50'); | ||
if (isImage(options.fileRecord.contentType)){ | ||
console.log('resizing'); | ||
var res = Imagemagick.resize({ | ||
srcData: options.blob, | ||
width: 50, | ||
height: 50, | ||
quality: 0.8, | ||
format: 'jpg' | ||
}); | ||
|
||
return { blob: res, fileRecord: options.fileRecord }; | ||
} else { | ||
return null; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
/** | ||
* @blob (https://developer.mozilla.org/en-US/docs/DOM/Blob) | ||
* @name the file's name | ||
* @type the file's type: binary, text (https://developer.mozilla.org/en-US/docs/DOM/FileReader#Methods) | ||
* | ||
* TODO Support other encodings: https://developer.mozilla.org/en-US/docs/DOM/FileReader#Methods | ||
* ArrayBuffer / DataURL (base64) | ||
*/ | ||
Meteor.uploadPicture = function(blob, name, callback) { | ||
var fileReader = new FileReader(), | ||
method = 'readAsBinaryString', encoding = 'binary'; | ||
|
||
fileReader.onload = function(file) { | ||
Meteor.call('uploadPicture', file.srcElement.result, name, '', encoding, callback); | ||
}; | ||
fileReader[method](blob); | ||
}; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.