-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 9fe1b4d
Showing
35 changed files
with
1,807 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file contains information which helps Meteor properly upgrade your | ||
# app when you run 'meteor update'. You should check it into version control | ||
# with your project. | ||
|
||
notices-for-0.9.0 | ||
notices-for-0.9.1 | ||
0.9.4-platform-file |
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 @@ | ||
local |
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,7 @@ | ||
# This file contains a token that is unique to your project. | ||
# Check it into your repository along with the rest of this directory. | ||
# It can be used for purposes such as: | ||
# - ensuring you don't accidentally deploy one app on top of another | ||
# - providing package authors with aggregated statistics | ||
|
||
zersw42p1g7c1lc05s2 |
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,14 @@ | ||
# Meteor packages used by this project, one per line. | ||
# Check this file (and the other files in this directory) into your repository. | ||
# | ||
# 'meteor add' and 'meteor remove' will edit this file for you, | ||
# but you can also edit it by hand. | ||
|
||
meteor-platform | ||
accounts-ui | ||
accounts-password | ||
accounts-facebook | ||
twbs:bootstrap | ||
http | ||
iron:router | ||
peppelg:bootstrap-3-modal |
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,2 @@ | ||
server | ||
browser |
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 @@ | ||
[email protected] |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Router.route('/',function(){ | ||
this.render('firstPage'); | ||
}); | ||
|
||
Router.route('/new-haiku',function(){ | ||
this.render('createNewHaiku'); | ||
}); | ||
|
||
Router.route('/haiku/:id',function(){ | ||
var haikuId = this.params.id; | ||
Session.set("redirectHaiku",haikuId); | ||
Router.go('/'); | ||
}); | ||
|
||
Router.route('/user/:id',function(){ | ||
var item = Meteor.users.findOne({_id: this.params.id}); | ||
if(!item){ | ||
Router.go('/'); | ||
} | ||
this.render('userProfile',{data: item}) | ||
}); | ||
/*Router.route('/user',function(){ | ||
this.render('userProfile') | ||
});*/ |
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,4 @@ | ||
Haikus = new Mongo.Collection('haikus'); | ||
Comments = new Mongo.Collection('comments'); | ||
Likes = new Mongo.Collection('likes'); | ||
Flickr = new Mongo.Collection('flickr'); |
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 @@ | ||
maxHaikusToShowOnEachPage = 100; | ||
|
||
facebookAppId = '100165010320303'; |
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,10 @@ | ||
flickrSearch = function(needle) { | ||
Meteor.call('flickrSearchPhotos', needle, function(error, result) { | ||
if (error) { | ||
console.error(error); | ||
return; | ||
} | ||
var photos = result; | ||
Session.set('flickrResults', photos); | ||
}); | ||
}; |
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,15 @@ | ||
getUsername = function(user){ | ||
if(user.username){ | ||
return user.username | ||
} | ||
else if(user.profile&&user.profile.name){ | ||
return user.profile.name; | ||
} | ||
else{ | ||
return user._id; | ||
} | ||
}; | ||
addAlignmentParametersToHaikus = function (document, index) { | ||
document.imagesSecond = index % 4 >= 2; | ||
return document; | ||
}; |
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,161 @@ | ||
var getUsernameOfCurrentUser = function(){ | ||
return getUsername(Meteor.user()); | ||
} | ||
|
||
Meteor.methods({ | ||
addHaiku: function(poemRow1, poemRow2, poemRow3, imageSrc) { | ||
// Make sure the user is logged in before inserting a task | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} | ||
else { | ||
|
||
if (!(typeof poemRow1 === "string" && typeof poemRow2 === "string" && typeof poemRow3 === "string" && typeof imageSrc === "string")) { | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
if (poemRow1.length > 50 || poemRow2.length > 50 || poemRow3.length > 50) { | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
//Insert into collection | ||
Haikus.insert({ | ||
poemRow1: poemRow1, | ||
poemRow2: poemRow2, | ||
poemRow3: poemRow3, | ||
imageSrc: imageSrc, | ||
shares: 0, | ||
createdAt: new Date(), | ||
owner: Meteor.userId(), | ||
username: getUsernameOfCurrentUser() | ||
}); | ||
} | ||
} | ||
} | ||
|
||
}, | ||
deleteHaiku: function(haikuId) { | ||
var haiku = Haikus.findOne(haikuId); | ||
if (haiku.owner !== Meteor.userId() || !Meteor.user()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} else { | ||
Likes.remove({haikuId: haikuId}); | ||
Comments.remove({haikuId: haikuId}); | ||
Haikus.remove({_id: haikuId}); | ||
} | ||
}, | ||
addRemoveLike: function(haikuId) { | ||
if (!Meteor.user()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} else { | ||
//Checks that the haikuId exists | ||
var haiku = Haikus.findOne({ | ||
_id: haikuId | ||
}); | ||
if (!haiku) { | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else{ | ||
var likeInfo = { | ||
userId: Meteor.userId(), | ||
haikuId: haikuId | ||
}; | ||
|
||
var existingLikes = Likes.findOne(likeInfo); | ||
|
||
if (existingLikes) { | ||
Likes.remove(likeInfo); | ||
} else { | ||
Likes.insert(likeInfo); | ||
} | ||
} | ||
} | ||
}, | ||
addComment: function(haikuId, text) { | ||
if (!Meteor.user()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} | ||
else { | ||
//Check if haikuId exists | ||
var haiku = Haikus.findOne({ | ||
_id: haikuId | ||
}); | ||
if (!haiku) { | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else{ | ||
if (!(typeof text === "string")) { | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
if(text.length>200){ | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
Comments.insert({ | ||
userId: Meteor.userId(), | ||
username: getUsernameOfCurrentUser(), | ||
haikuId: haikuId, | ||
text: text | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
removeComment: function(commentId) { | ||
var comment = Comments.findOne({ | ||
_id: commentId | ||
}); | ||
var commentingUserId = comment["userId"]; | ||
|
||
if (commentingUserId !== Meteor.userId() || !Meteor.user()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} else { | ||
Comments.remove({ | ||
_id: commentId | ||
}); | ||
} | ||
}, | ||
addToShareCount: function(haikuId){ | ||
Haikus.update( | ||
{ | ||
_id: haikuId | ||
}, | ||
{ | ||
$inc: { | ||
shares:1 | ||
} | ||
} | ||
) | ||
}, | ||
userDescription: function(userDescriptionInput) { | ||
if (!Meteor.user()) { | ||
throw new Meteor.Error("not-authorized"); | ||
} | ||
else { | ||
if(typeof userDescriptionInput !== "string"){ | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
if(userDescriptionInput.length>200){ | ||
throw new Meteor.Error("incorrect-input"); | ||
} | ||
else { | ||
Meteor.users.update( | ||
{ | ||
_id: Meteor.userId() | ||
}, | ||
{ | ||
$set: { | ||
userDescription: userDescriptionInput | ||
} | ||
} | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
}); |
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,37 @@ | ||
Meteor.subscribe('haikus'); | ||
Meteor.subscribe("likes"); | ||
Meteor.subscribe('comments'); | ||
Meteor.subscribe('users'); | ||
|
||
Session.set('appName', 'Haiku 俳句'); | ||
Session.set('lastImageSearch', new Date()); | ||
document.title = Session.get('appName'); | ||
|
||
|
||
|
||
Template.registerHelper("isLoggedIn",function(){ | ||
return Boolean(Meteor.userId()); | ||
}); | ||
|
||
Accounts.ui.config({ | ||
passwordSignupFields: "USERNAME_ONLY" | ||
}); | ||
|
||
shareConfig = { | ||
|
||
}; | ||
|
||
var userWasLoggedIn = false; | ||
Deps.autorun(function (c) { | ||
if(!Meteor.userId()) | ||
{ | ||
if(userWasLoggedIn) | ||
{ | ||
Router.go("/"); | ||
} | ||
} | ||
else | ||
{ | ||
userWasLoggedIn = true; | ||
} | ||
}); |
Oops, something went wrong.