Skip to content

Commit

Permalink
Added everything from old repo
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoman2 committed Jan 31, 2017
0 parents commit 9fe1b4d
Show file tree
Hide file tree
Showing 35 changed files with 1,807 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .meteor/.finished-upgraders
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
1 change: 1 addition & 0 deletions .meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions .meteor/.id
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
14 changes: 14 additions & 0 deletions .meteor/packages
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
2 changes: 2 additions & 0 deletions .meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions .meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
72 changes: 72 additions & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
iron:[email protected]
[email protected]_2
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_2
[email protected]
[email protected]
[email protected]
[email protected]
peppelg:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
twbs:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
24 changes: 24 additions & 0 deletions both/Router.js
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')
});*/
4 changes: 4 additions & 0 deletions both/collections.js
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');
3 changes: 3 additions & 0 deletions both/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
maxHaikusToShowOnEachPage = 100;

facebookAppId = '100165010320303';
10 changes: 10 additions & 0 deletions both/flickr.js
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);
});
};
15 changes: 15 additions & 0 deletions both/globalFunctions.js
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;
};
161 changes: 161 additions & 0 deletions both/methods.js
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
}
}
);
}
}
}
}


});
37 changes: 37 additions & 0 deletions client/client.js
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;
}
});
Loading

0 comments on commit 9fe1b4d

Please sign in to comment.