From 9fe1b4d822b740fcf159a9c52bfef6779473c82b Mon Sep 17 00:00:00 2001 From: jojoman2 Date: Tue, 31 Jan 2017 13:18:44 +0100 Subject: [PATCH] Added everything from old repo --- .meteor/.finished-upgraders | 7 + .meteor/.gitignore | 1 + .meteor/.id | 7 + .meteor/packages | 14 + .meteor/platforms | 2 + .meteor/release | 1 + .meteor/versions | 72 +++++ both/Router.js | 24 ++ both/collections.js | 4 + both/constants.js | 3 + both/flickr.js | 10 + both/globalFunctions.js | 15 + both/methods.js | 161 ++++++++++ client/client.js | 37 +++ client/createNewHaiku.html | 65 +++++ client/createNewHaiku.js | 80 +++++ client/firstPage.html | 34 +++ client/firstPage.js | 128 ++++++++ client/haiku.html | 34 +++ client/haiku.js | 12 + client/haikuPopup.html | 88 ++++++ client/haikuPopup.js | 114 ++++++++ client/inspiration-flickr.html | 29 ++ client/inspiration-flickr.js | 77 +++++ client/nav.html | 30 ++ client/nav.js | 46 +++ client/style.css | 471 ++++++++++++++++++++++++++++++ client/userProfile.html | 56 ++++ client/userProfile.js | 59 ++++ packages.json | 3 + packages/npm-container/index.js | 9 + packages/npm-container/package.js | 23 ++ public/js/share.min.js | 3 + server/flickr.js | 61 ++++ server/server.js | 27 ++ 35 files changed, 1807 insertions(+) create mode 100644 .meteor/.finished-upgraders create mode 100644 .meteor/.gitignore create mode 100644 .meteor/.id create mode 100644 .meteor/packages create mode 100644 .meteor/platforms create mode 100644 .meteor/release create mode 100644 .meteor/versions create mode 100644 both/Router.js create mode 100644 both/collections.js create mode 100644 both/constants.js create mode 100644 both/flickr.js create mode 100644 both/globalFunctions.js create mode 100644 both/methods.js create mode 100644 client/client.js create mode 100644 client/createNewHaiku.html create mode 100644 client/createNewHaiku.js create mode 100644 client/firstPage.html create mode 100644 client/firstPage.js create mode 100644 client/haiku.html create mode 100644 client/haiku.js create mode 100644 client/haikuPopup.html create mode 100644 client/haikuPopup.js create mode 100644 client/inspiration-flickr.html create mode 100644 client/inspiration-flickr.js create mode 100644 client/nav.html create mode 100644 client/nav.js create mode 100644 client/style.css create mode 100644 client/userProfile.html create mode 100644 client/userProfile.js create mode 100644 packages.json create mode 100644 packages/npm-container/index.js create mode 100644 packages/npm-container/package.js create mode 100644 public/js/share.min.js create mode 100644 server/flickr.js create mode 100644 server/server.js diff --git a/.meteor/.finished-upgraders b/.meteor/.finished-upgraders new file mode 100644 index 0000000..68df3d8 --- /dev/null +++ b/.meteor/.finished-upgraders @@ -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 diff --git a/.meteor/.gitignore b/.meteor/.gitignore new file mode 100644 index 0000000..4083037 --- /dev/null +++ b/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/.meteor/.id b/.meteor/.id new file mode 100644 index 0000000..d26ee69 --- /dev/null +++ b/.meteor/.id @@ -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 diff --git a/.meteor/packages b/.meteor/packages new file mode 100644 index 0000000..301e3da --- /dev/null +++ b/.meteor/packages @@ -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 diff --git a/.meteor/platforms b/.meteor/platforms new file mode 100644 index 0000000..efeba1b --- /dev/null +++ b/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/.meteor/release b/.meteor/release new file mode 100644 index 0000000..cb24d42 --- /dev/null +++ b/.meteor/release @@ -0,0 +1 @@ +WINDOWS-PREVIEW@0.3.0 diff --git a/.meteor/versions b/.meteor/versions new file mode 100644 index 0000000..d972656 --- /dev/null +++ b/.meteor/versions @@ -0,0 +1,72 @@ +accounts-base@1.2.0-rc.0 +accounts-facebook@1.0.4-rc.0 +accounts-oauth@1.1.4-rc.0 +accounts-password@1.1.0-win.1 +accounts-ui@1.1.5-rc.0 +accounts-ui-unstyled@1.1.7-rc.0 +autoupdate@1.2.0-win.0 +base64@1.0.3-rc.0 +binary-heap@1.0.3-rc.0 +blaze@2.1.0-rc.2 +blaze-tools@1.0.3-rc.0 +boilerplate-generator@1.0.3-rc.0 +callback-hook@1.0.3-rc.0 +check@1.0.5-rc.0 +ddp@1.1.0-rc.1 +deps@1.0.7-rc.0 +ejson@1.0.6-rc.0 +email@1.0.6-rc.0 +facebook@1.1.4-rc.0 +fastclick@1.0.3-rc.0 +geojson-utils@1.0.3-rc.0 +html-tools@1.0.4-rc.0 +htmljs@1.0.4-rc.0 +http@1.1.0-rc.0 +id-map@1.0.3-rc.0 +iron:controller@1.0.8 +iron:core@1.0.11 +iron:dynamic-template@1.0.8 +iron:layout@1.0.8 +iron:location@1.0.11 +iron:middleware-stack@1.1.0 +iron:router@1.0.9 +iron:url@1.0.11 +jquery@1.11.3-rc.0_2 +json@1.0.3-rc.0 +launch-screen@1.0.2-rc.0 +less@1.0.13-rc.2 +livedata@1.0.13-rc.0 +localstorage@1.0.3-rc.0 +logging@1.0.7-rc.0 +meteor@1.1.5-rc.0 +meteor-platform@1.2.2-rc.0 +minifiers@1.1.4-win.0 +minimongo@1.0.7-rc.0 +mobile-status-bar@1.0.3-rc.0 +mongo@1.1.0-rc.0 +npm-bcrypt@0.7.8_2 +oauth@1.1.4-rc.0 +oauth2@1.1.3-rc.0 +observe-sequence@1.0.5-win.0 +ordered-dict@1.0.3-rc.0 +peppelg:bootstrap-3-modal@1.0.2 +random@1.0.3-rc.0 +reactive-dict@1.1.0-rc.0 +reactive-var@1.0.5-rc.0 +reload@1.1.3-rc.0 +retry@1.0.3-rc.0 +routepolicy@1.0.5-rc.0 +service-configuration@1.0.4-rc.0 +session@1.1.0-rc.0 +sha@1.0.3-rc.0 +spacebars@1.0.6-rc.0 +spacebars-compiler@1.0.5-rc.0 +srp@1.0.3-rc.0 +templating@1.1.0-win.0 +tracker@1.0.6-win.0 +twbs:bootstrap@3.3.6 +ui@1.0.6-rc.0 +underscore@1.0.3-rc.0 +url@1.0.4-rc.0 +webapp@1.2.0-rc.1 +webapp-hashing@1.0.3-rc.0 diff --git a/both/Router.js b/both/Router.js new file mode 100644 index 0000000..8784ed1 --- /dev/null +++ b/both/Router.js @@ -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') +});*/ \ No newline at end of file diff --git a/both/collections.js b/both/collections.js new file mode 100644 index 0000000..43f9f29 --- /dev/null +++ b/both/collections.js @@ -0,0 +1,4 @@ +Haikus = new Mongo.Collection('haikus'); +Comments = new Mongo.Collection('comments'); +Likes = new Mongo.Collection('likes'); +Flickr = new Mongo.Collection('flickr'); \ No newline at end of file diff --git a/both/constants.js b/both/constants.js new file mode 100644 index 0000000..18bae8d --- /dev/null +++ b/both/constants.js @@ -0,0 +1,3 @@ +maxHaikusToShowOnEachPage = 100; + +facebookAppId = '100165010320303'; diff --git a/both/flickr.js b/both/flickr.js new file mode 100644 index 0000000..fb186ec --- /dev/null +++ b/both/flickr.js @@ -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); + }); +}; \ No newline at end of file diff --git a/both/globalFunctions.js b/both/globalFunctions.js new file mode 100644 index 0000000..7edf5e6 --- /dev/null +++ b/both/globalFunctions.js @@ -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; +}; \ No newline at end of file diff --git a/both/methods.js b/both/methods.js new file mode 100644 index 0000000..5c9a855 --- /dev/null +++ b/both/methods.js @@ -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 + } + } + ); + } + } + } + } + + +}); \ No newline at end of file diff --git a/client/client.js b/client/client.js new file mode 100644 index 0000000..ea5ad99 --- /dev/null +++ b/client/client.js @@ -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; + } +}); \ No newline at end of file diff --git a/client/createNewHaiku.html b/client/createNewHaiku.html new file mode 100644 index 0000000..9be939b --- /dev/null +++ b/client/createNewHaiku.html @@ -0,0 +1,65 @@ + diff --git a/client/createNewHaiku.js b/client/createNewHaiku.js new file mode 100644 index 0000000..b661f3d --- /dev/null +++ b/client/createNewHaiku.js @@ -0,0 +1,80 @@ + +Session.set('haikuImage', { + id: '16287638134', + owner: '130080108@N02', + secret: 'd3ff2ffc58', + server: '7281', + farm: 8, + title: 'Landscape 5 By: Anton Antonov', + ispublic: 1, + isfriend: 0, + isfamily: 0 +}); + +var imgSearchSpawn = function(event, template) { + var lastSearchTime = Session.get('lastImageSearch'); + + if (new Date() - lastSearchTime > 5000) { + var words = template.find("#row1").value.split(' ').concat( + template.find("#row2").value.split(' ')).concat( + template.find("#row3").value.split(' ')); + var needle = words[Math.floor(Math.random() * words.length)]; + console.log('Searching for inspiration. Term: ', needle); + + flickrSearch(needle); + Session.set('lastImageSearch', new Date()); + } +}; + +Template.createNewHaiku.events({ + "keyup #row1": imgSearchSpawn, + "keyup #row2": imgSearchSpawn, + "keyup #row3": imgSearchSpawn, + "click #postHaikuBtn": function(event, template) { + var row1 = template.find("#row1").value; + var row2 = template.find("#row2").value; + var row3 = template.find("#row3").value; + + var theImageToUse = urlFromFlickrPhoto(Session.get('haikuImage')); + Meteor.call('addHaiku', row1, row2, row3, theImageToUse); + Session.set("haiku-display","latest"); + Router.go('/'); + }, + "click #font-chooser li a": function(event) { + chosenFont = event.target.innerHTML; + }, + "click #color-chooser li a": function(event) { + chosenColor = event.target.innerHTML; + }, + "click #refresh-image": function(event) { + var hej = Session.get('flickrResults'); + if (hej && hej.photos && hej.photos.photo){ + if (hej.photos.photo.length>0){ + Session.set('haikuImage', randomFlickrPhoto()); + } + } + } +}); + + +Template.createNewHaiku.helpers({ + getAvailableFontNames: function() { + var fontNames = []; + for (var i = 0; i < availableTextFonts.length; i++) { + fontNames.push(availableTextFonts[i].name); + } + return fontNames; + }, + getAvailableColorNames: function() { + var colorNames = []; + for (var i = 0; i < availableTextColors.length; i++) { + colorNames.push(availableTextColors[i].name) + } + return colorNames; + }, + haikuImage: function() { + var i = Session.get('haikuImage'); + console.log('Image: ',i); + return i; + } +}); \ No newline at end of file diff --git a/client/firstPage.html b/client/firstPage.html new file mode 100644 index 0000000..04aee84 --- /dev/null +++ b/client/firstPage.html @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/client/firstPage.js b/client/firstPage.js new file mode 100644 index 0000000..55ac478 --- /dev/null +++ b/client/firstPage.js @@ -0,0 +1,128 @@ +/** + * Created by Fredrik on 2015-04-16. + */ + var mostLikedHaikus = function(){ + + var likes = Likes.find().fetch(); + var likesByHaiku = _.groupBy(_.pluck(likes, 'haikuId')); + + var arrayOfHaikus = []; + var haikusWithLikes = {}; + _.each(_.values(likesByHaiku), function (haikus) { + arrayOfHaikus.push([haikus[0], haikus.length]); + haikusWithLikes[haikus[0]] = true; + }); + + arrayOfHaikus.sort(function (a, b) { + return b[1] - a[1]; + }); + + var numberOfHaikusToAdd = Math.min(arrayOfHaikus.length, maxHaikusToShowOnEachPage); + + var haikusToDisplay = []; + for (var i = 0; i < numberOfHaikusToAdd; i++) { + var currHaiku = Haikus.findOne({_id: arrayOfHaikus[i][0]}); + currHaiku["imagesSecond"] = i % 4 >= 2; + haikusToDisplay.push(currHaiku); + } + + if (arrayOfHaikus.length < maxHaikusToShowOnEachPage) { + Haikus.find().forEach(function (haiku) { + var lengthOfHaikuList = haikusToDisplay.length; + if(lengthOfHaikuList >= maxHaikusToShowOnEachPage){ + return false; + } + + if (!haikusWithLikes[haiku._id]) { + haiku["imagesSecond"] = lengthOfHaikuList % 4 >= 2; + haikusToDisplay.push(haiku); + } + }); + } + + return haikusToDisplay; +}; + +var latestHaikus = function() { + return Haikus.find({}, {sort: {createdAt: -1}, limit: maxHaikusToShowOnEachPage}).map(addAlignmentParametersToHaikus); +}; + +var searchHaikus = function(searchWord) { + return Haikus.find({$or : [ + {poemRow1:{$regex:searchWord, $options: 'i'} }, + {poemRow2:{$regex:searchWord, $options: 'i'} }, + {poemRow3:{$regex:searchWord, $options: 'i'} } ] + }).map(addAlignmentParametersToHaikus); +}; + +var mostSharedHaikus = function(){ + return Haikus.find( + {}, + { + sort:{shares:-1} + } + + ).map(addAlignmentParametersToHaikus); +}; + + + + +Template.firstPage.helpers({ + getPopupTemplate: function(){ + return + }, + getHaikus :function(){ + var searchTerm = Session.get("searchTerm"); + if(searchTerm){ + return searchHaikus(searchTerm); + } + var haikuToDisplay = Session.get("haiku-display") + if(haikuToDisplay === 'most-liked'){ + return mostLikedHaikus(); + } + else if(haikuToDisplay ==='most-shared'){ + return mostSharedHaikus(); + } + else{ + return latestHaikus(); + } + }, + textAboutHaikuDisplayed : function(){ + var searchTerm = Session.get("searchTerm"); + var haikuDisplayed = Session.get("haiku-display"); + if(searchTerm){ + return "search for "+searchTerm; + } + if(haikuDisplayed === 'most-liked'){ + return "most liked haikus..."; + } + else if(haikuDisplayed === 'most-shared'){ + return "most shared haikus..."; + } + else{ + return "latest haikus..."; + } + }, + appname: function() { + return Session.get('appName'); + } +}); + +Template.firstPage.events({ + "click #app-icon" : function(){ + Session.set("searchTerm",null); + $("#searchString").val(""); + } +}); + +Meteor.subscribe("haikus", function() { + Session.set("searchTerm",null); + var redirectHaiku = Session.get("redirectHaiku"); + if(redirectHaiku){ + Session.set("redirectHaiku",null); + var haikuData = Haikus.findOne({_id:redirectHaiku}); + Session.set("haikuData",haikuData); + Modal.show('haikuPopup',haikuData); + } +}); diff --git a/client/haiku.html b/client/haiku.html new file mode 100644 index 0000000..4e3af57 --- /dev/null +++ b/client/haiku.html @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/client/haiku.js b/client/haiku.js new file mode 100644 index 0000000..f437141 --- /dev/null +++ b/client/haiku.js @@ -0,0 +1,12 @@ +/** + * Created by Fredrik on 2015-04-19. + */ +Template.haiku.events({ + "click .haikuDiv" : function(){ + var id = this._id; + + var haikuData = Haikus.findOne({_id:id}); + Session.set("haikuData",haikuData); + Modal.show('haikuPopup',haikuData); + } +}); \ No newline at end of file diff --git a/client/haikuPopup.html b/client/haikuPopup.html new file mode 100644 index 0000000..9a026f1 --- /dev/null +++ b/client/haikuPopup.html @@ -0,0 +1,88 @@ + \ No newline at end of file diff --git a/client/haikuPopup.js b/client/haikuPopup.js new file mode 100644 index 0000000..1755c08 --- /dev/null +++ b/client/haikuPopup.js @@ -0,0 +1,114 @@ +/** + * Created by Fredrik on 2015-04-16. + */ + +var reportShare = function(haikuId){ + Meteor.call("addToShareCount",haikuId); +}; + +var getNumberOfLikers = function(haikuId){ + var result = Likes.find({haikuId: haikuId}); + return result.count(); +}; + +Template.haikuPopup.helpers({ + "colorToUse" : function(haikuId) { + var result = Likes.findOne({userId: Meteor.userId(), haikuId: haikuId}); + if (!result) { + return "gray"; + } + return "red"; + + /*console.log(result); + var liked = result.count() > 0; + return liked ? "blue" : "black";*/ + }, + "getNumberOfLikers" : function () { + return getNumberOfLikers(this._id); + }, + "hasMoreThanOneLiker" : function(){ + return getNumberOfLikers(this._id)>0; + }, + "getComments" : function(){ + return Comments.find({haikuId: this._id}) + } +}); + +Template.haikuPopup.events({ + "click #likeButton" : function(){ + Meteor.call('addRemoveLike',this._id); + }, + + "click #commentButton" : function(){ + $('#editUserComment').slideToggle("fast"); + }, + + "click #postHaikuCommentButton" : function(event, template){ + event.preventDefault(); + if(template.find("#userComment").value!=""){ + var commentToPost = template.find("#userComment").value; + var haikuId = this._id; + Meteor.call('addComment',haikuId,commentToPost); + template.find("#userComment").value(''); + } + }, + "click #usernameLink" : function(event){ + event.preventDefault(); + Router.go("/user/"+this.owner); + $(window).scrollTop(0); + Modal.hide(this); + } + + +}); + +Template.haikuPopup.created = function(){ + var haikuData = Session.get("haikuData"); + Session.set("haikuData",null); + var haikuId = haikuData._id; + var domainAddress = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: ''); + var appName = Session.get("appName"); + var shareConfig = { + url : domainAddress+"/haiku/"+haikuId, + title: appName, + description: haikuData.poemRow1+"\n"+haikuData.poemRow2+"\n"+haikuData.poemRow3, + image: haikuData.imageSrc, + networks: { + google_plus: { + after: function() { + reportShare(haikuId) + } + }, + twitter: { + after: function() { + reportShare(haikuId) + } + }, + facebook: { + app_id: '100165010320303', + load_sdk: true, + after: function() { + reportShare(haikuId) + } + }, + pinterest:{ + after: function(){ + reportShare(haikuId) + } + }, + email:{ + after: function(){ + reportShare(haikuId) + } + } + + + } + + }; + + $.getScript("/js/share.min.js", function () { + new Share("#shareButton",shareConfig); + }); + +}; \ No newline at end of file diff --git a/client/inspiration-flickr.html b/client/inspiration-flickr.html new file mode 100644 index 0000000..88793a5 --- /dev/null +++ b/client/inspiration-flickr.html @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/client/inspiration-flickr.js b/client/inspiration-flickr.js new file mode 100644 index 0000000..dd0463f --- /dev/null +++ b/client/inspiration-flickr.js @@ -0,0 +1,77 @@ +Meteor.subscribe('flickr'); + +var url = function(farm, server, id, secret, size) { + if (!size) { + size = ''; + } + return 'https://farm' + farm + '.staticflickr.com/' + server + '/' + id + '_' + secret + size + '.jpg'; +}; + +flickrPhotosInSession = function() { + var flickrPhotos = Session.get('flickrResults'); + if (flickrPhotos && flickrPhotos.photos && flickrPhotos.photos.photo) { + return flickrPhotos.photos.photo; + } else { + return []; + } +}; + +randomFlickrPhoto = function() { + var photos = flickrPhotosInSession(); + return photos[Math.floor(Math.random()*(photos.length-1))]; +}; + +urlFromFlickrPhoto = function(photo) { + return url(photo.farm, photo.server, photo.id, photo.secret, ''); +}; + + +/*Session.set('flickrResults', { + photos: { + photo: [{ + id: '16287638134', + owner: '130080108@N02', + secret: 'd3ff2ffc58', + server: '7281', + farm: 8, + title: 'Landscape 5 By: Anton Antonov', + ispublic: 1, + isfriend: 0, + isfamily: 0 + }], + }, +}); +*/ + + +Template.flickrtest.events({ + 'submit': function(event) { + var needle = event.target.needle.value; + flickrSearch(needle); + event.preventDefault(); + } +}); + +Template.inspirationPhotos.helpers({ + flickrPhotos: flickrPhotosInSession, + // Uses the url api + // https://www.flickr.com/services/api/misc.urls.html +}); + +Template.flickrLargeSquare.helpers({ + url: function(farm, server, id, secret) { + return url(farm, server, id, secret, '_q'); + } +}); + +Template.flickrSquare.helpers({ + url: function(farm, server, id, secret) { + return url(farm, server, id, secret, '_s'); + } +}); + +Template.flickrPhoto.helpers({ + url: function(farm, server, id, secret) { + return url(farm, server, id, secret, ''); + }, +}) \ No newline at end of file diff --git a/client/nav.html b/client/nav.html new file mode 100644 index 0000000..5542e40 --- /dev/null +++ b/client/nav.html @@ -0,0 +1,30 @@ + diff --git a/client/nav.js b/client/nav.js new file mode 100644 index 0000000..483789b --- /dev/null +++ b/client/nav.js @@ -0,0 +1,46 @@ +var toFirstPageIfNotThere = function(){ + var location = Iron.Location.get().pathname; + if(location !== "/"){ + Router.go("/"); + } +}; +var resestSearchString = function(){ + $("#searchString").val(""); + Session.set("searchTerm",null); +}; + +Template.nav.helpers({ + appname: function() { + return Session.get('appName'); + }, + getUserId : function() { + return Meteor.userId(); + } +}); + +Template.nav.events({ + "click #most-liked-haikus" : function(){ + Session.set("haiku-display","most-liked"); + toFirstPageIfNotThere(); + resestSearchString(); + }, + "click #most-shared-haikus" : function(){ + Session.set("haiku-display","most-shared"); + toFirstPageIfNotThere(); + resestSearchString(); + }, + "click #app-icon" : function(){ + Session.set("haiku-display","latest"); + resestSearchString(); + }, + "click #searchBtn" : function(event,template){ + var searchString = template.find("#searchString").value; + $("#searchString").val(""); + Session.set("searchTerm",searchString); + } +}); + + +Template.nav.rendered = function(){ + $('.login-link-text').addClass('btn'); +}; diff --git a/client/style.css b/client/style.css new file mode 100644 index 0000000..1f4e476 --- /dev/null +++ b/client/style.css @@ -0,0 +1,471 @@ +body { + font-family: 'Open Sans', sans-serif; + /*font-family: 'Indie Flower', cursive;*/ + /*background-color: #CEF9CE;*/ + background-color: #E2EAE2; + background-attachment: fixed; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + padding-top: 70px; + margin: 0; + font-size: 120%; +} +.container { + margin: 0 auto; + background: inherit; + padding: 0; +} +header { + /*background: #144914;*/ + background: #112611; + width: 100%; + padding: 20px 15px 15px 15px; + position: fixed; + z-index: 10; +} +.navbar-form { + float: inherit; +} +#login-buttons { + display: block; + float: right; +} +#login-buttons #login-dropdown-list { + position: absolute; + top: -1px; + right: 0; + left: inherit; +} +#login-buttons a, #login-buttons a:visited, #login-buttons a:active{ + color: #eee; +} +#login-buttons a:focus, #login-buttons a:hover { + color: #fff; +} +.login-link-text{ + font-size: 15px; +} +#firstPage { + /*background: #E4FDE4;*/ + background: #E2EAE2; +} +#firstPageColumn1 { + padding: 0; + background: #fff; + max-height: 273px; + /*border-color: #FFFFFF; + border-style: double;*/ +} +#firstPageColumn1MODAL { + padding: 0; + background: #fff; +} +#firstPageColumn1:hover { + -moz-box-shadow: 0 0 40px #112611; + -webkit-box-shadow: 0 0 40px #112611; + box-shadow: 0 0 40px #112611; + z-index: 10; +} +.modal { + /*border-style: solid; + border-color: #000000; + border-radius: 10px; + opacity: 0.9;*/ +} +.modal-header { + background: #FFFFFF; +} +.modal-footer { + background: #FFFFFF; +} +.modal-body{ + background: #FFFFFF; +} +#userProfilePage{ + padding: 0; +} +#userProfileDiv { + width: 100%; + height: auto; + background: #E2EAE2; + /*border-color: #112611; + border-style: double;*/ + padding: 0; + margin-bottom: 2px; +} +#totalLikes { + text-align: center; + padding-top: 1.5em; +} +#totalPosts { + text-align: center; + padding-top: 1.5em; +} +#userDescription{ +} +#userPhoto { + padding: 0; +} +#cover { + position: fixed; + top: 0; + left: 0; + background: rgba(0, 0, 0, 0.6); + z-index: 5; + width: 100%; + height: 100%; + display: none; +} +#popUpHaiku { + height: 500px; + width: 500px; + margin: 0 auto; + position: relative; + z-index: 10; + display: none; + background: url(login.png) + no-repeat; + border: 5px double #cccccc; + border-radius: 0px; +} + +#popUpHaiku:target, #popUpHaiku:target + #cover { + background: #fff; + display: block; + opacity: 2; +} +.cancel { + display: block; + position: absolute; + top: 3px; + right: 2px; + background: rgb(245, 245, 245); + color: black; + height: 30px; + width: 35px; + font-size: 30px; + text-decoration: none; + text-align: center; + font-weight: bold; +} + +#commentArea { + background: #FFFFFF; + max-height: 70px; + width: 100%; + overflow-y: auto; + float: left; + clear:both; + text-align: left; +} + +.comment { + margin-top: 5px; +} + +#createNewHaiku { + background: rgba(255,255,255,0); + /*border-color: #112611; + border-style: none; + border-radius: 5px 5px;*/ +} + +#imageAndTextDiv { + background: #fff; + /*border-color: #112611; + border-style: double;*/ + overflow: hidden; +} + +#imageAndTextDiv form { + margin: 20% 0; +} + +#createNewHaikuImage { + /*padding: 0;*/ + background-position: 50% 25%; + background-size: cover; +} +#createNewHaikuImage img { + padding: 0; + height: 450px; + width: 450px; +} +#myProfile { +} +#login-buttons .login-button, .accounts-dialog .login-button { + background: white; + font-family: 'Open Sans', sans-serif; + color: #000000; + border-color: #112611; +} +#login-buttons .login-button:hover, .accounts-dialog .login-button:hover { + background: #112611; + color: #FFFFFF; +} + +#login-buttons a { + color: #000000; +} + +#login-buttons:hover a { + color: #112611; +} + +#login-sign-in-link,#login-sign-in-link:hover{ + color: #FFFFFF !important; +} + + +#login-buttons #login-name-link { + color: #FFFFFF; +} +#login-buttons #login-sign-in-link{ + color: #FFFFFF; +} + +/* +#haikuImage img { + width: 100%; + height: auto; + display: block; + margin: 0; + /*border-radius: 5px 5px; + border: #000 double; +} +*/ +#haikuImage { + height: 273px; + padding: 0; + background-position: 50% 25%; + background-size: cover; +} +#haikuImageMODAL { + + height: 431px; + padding: 0; + background-position: 50% 25%; + background-size: cover; +} +#haikuText { + text-align: center; + padding: 0; + background: rgba(255,255,255,0.8); + /*border-radius: 5px 5px;*/ + margin: 0; +} +#createHaikuText { + text-align: center; + padding: 0; + padding-left: 5%; + padding-right: 5%; + background: rgba(255,255,255,0.8); + /*border-radius: 5px 5px;*/ + margin: 0; +} +.haikuInput { + width: 100%; +} +#likeButton { + float: left; + padding-right: 10px; +} +.glyphicon.glyphicon-heart { + font-size: 30px; + opacity: 0.90; +} +.glyphicon.glyphicon-heart:hover { + opacity: 1.0; +} +#commentButton { + float: left; + padding-right: 10px; + display:inline +} + +#commentButton a { + color: #000000; +} +.glyphicon.glyphicon-comment { + font-size: 30px; + color: gray; + opacity: 0.9; +} +.glyphicon.glyphicon-comment:hover { + opacity: 1.0; +} +#editUserComment { + float: left; + margin-left: 0px; + padding-top: 0px; + display:inline +} +#userComment { + width: 70%; + float: left; + margin-right: 1px; +} +#username a { + text-decoration: underline; + color: black; +} +#username a:hover{ + color: gray; + text-decoration: none !important; +} +/* +#username h3 { + color: #FFFFFF; +} +.close { + color: #FFFFFF; +} +.close:hover { + color: #FFFFFF; +}*/ +#postHaikuCommentButton { + float: left; + display:inline, + margin-left: 10px; +} +#shareButton { + float: right; + background: #FFFFFF; +} + +.sharer-0 label span { + font-family: 'Open Sans', sans-serif !important; +} + +.sharer-0 label { + background: #FFFFFF !important; +} +.sharer-0 label:hover { + background: #e6e6e6; +} +#footerButtons { + display: inline; + padding: 1px; +} +#footerButtons form { + /*padding-top: 13px;*/ + display: inline; + float: left; +} +#haikuText p, #createHaikuText p { + font-family: 'Indie Flower', cursive; + font-size: 140%; + color: gray; + /*margin: 10px auto;*/ +} +.haikuTextModal { + font-family: 'Indie Flower', cursive; + font-size: 200%; + color: gray; + margin: 10px auto; +} +#editDiv { + padding-top: 10px; + padding-bottom: 10px; +} +#postBtnDiv { + padding-top: 10px; + padding-bottom: 10px; +} +#postHaikuBtn { + float: right; + padding-top: 10px; +} +div.feature { + position: relative; +} +div.feature a { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + text-decoration: none; /* No underlines on the link */ + z-index: 10; /* Places the link above everything else in the div */ + background-color: #FFF; /* Fix to make div clickable in IE */ + opacity: 0; /* Fix to make div clickable in IE */ + filter: alpha(opacity=1); /* Fix to make div clickable in IE */ +} +h1 { + font-size: 2em; + color: #E2EAE2; + margin: 0; + margin-bottom: 0; + display: inline-block; + margin-right: 1em; +} +.new-task input { + box-sizing: border-box; + padding: 10px 0; + background: transparent; + border: none; + width: 100%; + padding-right: 80px; + font-size: 1em; +} +.new-task input:focus { + outline: 0; +} +.delete { + float: right; + font-weight: bold; + background: none; + font-size: 1em; + border: none; + position: relative; +} +li { + position: relative; + list-style: none; + padding: 15px; + border-bottom: #eee solid 1px; +} +li .text { + margin-left: 10px; +} +li.checked { + color: #888; +} +li.checked .text { + text-decoration: line-through; +} +li.private { + background: #eee; + border-color: #ddd; +} +header .hide-completed { + float: right; +} +.toggle-private { + margin-left: 5px; +} +.inspiration { + position: fixed; + top: 70px; + z-index: -100; + min-width: 123%; +} +.inspiration .inspirationPhoto { + float: left; + display: block; +} +@media (max-width:600px) { + li { + padding: 12px 15px; + } + .search { + width: 150px; + clear: both; + } + .new-task input { + padding-bottom: 5px; + } +} diff --git a/client/userProfile.html b/client/userProfile.html new file mode 100644 index 0000000..68379cd --- /dev/null +++ b/client/userProfile.html @@ -0,0 +1,56 @@ + + + \ No newline at end of file diff --git a/client/userProfile.js b/client/userProfile.js new file mode 100644 index 0000000..f0176dc --- /dev/null +++ b/client/userProfile.js @@ -0,0 +1,59 @@ +var isThisUser = function(viewedUserId){ + return Meteor.userId() === viewedUserId; +}; + +Template.userProfile.events({ + "blur #userDescriptionInput": function(event,template) { + var userDescriptionInput = $('#userDescriptionInput').val(); + + $(template.find('#inputDescription')).hide(); + var userInputText = $(template.find('#userDescriptionText')); + userInputText.show(); + + Meteor.call('userDescription', userDescriptionInput); + }, + + "click #userDescriptionText": function(event,template) { + if(isThisUser(this._id)) { + $(template.find('#inputDescription')).show(); + $(template.find('#userDescriptionInput')).focus(); + $(template.find('#userDescriptionText')).hide(); + + } + } +}); + +Template.userProfile.helpers({ + "getUsername" : function(){ + return getUsername(this); + }, + "isThisUser" : function(){ + return isThisUser(this._id); + }, + "descriptionText" : function(){ + if(this.userDescription){ + return this.userDescription; + } + else if(isThisUser(this._id)){ + return "Click here to update your description"; + } + else{ + return ""; + } + }, + getNumberOfPosts : function(){ + return Haikus.find({owner:this._id}).count(); + }, + getNumberOfLikers : function(){ + var totalLikes = 0; + + var postedHaikus = Haikus.find({owner:this._id},{_id:true}); + postedHaikus.forEach(function(haiku){ + totalLikes += Likes.find({haikuId: haiku._id}).count(); + }); + return totalLikes; + }, + "getHaikus" : function(){ + return Haikus.find({owner:this._id}, {sort: {createdAt: -1}}).map(addAlignmentParametersToHaikus); + } +}); \ No newline at end of file diff --git a/packages.json b/packages.json new file mode 100644 index 0000000..4eb7c3f --- /dev/null +++ b/packages.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/packages/npm-container/index.js b/packages/npm-container/index.js new file mode 100644 index 0000000..c3fc862 --- /dev/null +++ b/packages/npm-container/index.js @@ -0,0 +1,9 @@ +Meteor.npmRequire = function(moduleName) { + var module = Npm.require(moduleName); + return module; +}; + +Meteor.require = function(moduleName) { + console.warn('Meteor.require is deprecated. Please use Meteor.npmRequire instead!'); + return Meteor.npmRequire(moduleName); +}; \ No newline at end of file diff --git a/packages/npm-container/package.js b/packages/npm-container/package.js new file mode 100644 index 0000000..674de02 --- /dev/null +++ b/packages/npm-container/package.js @@ -0,0 +1,23 @@ +var path = Npm.require('path'); +var fs = Npm.require('fs'); + +Package.describe({ + summary: 'Contains all your npm dependencies', + version: '1.0.0', + name: 'npm-container' +}); + +var packagesJsonFile = path.resolve('./packages.json'); +try { + var fileContent = fs.readFileSync(packagesJsonFile); + var packages = JSON.parse(fileContent.toString()); + Npm.depends(packages); +} catch (ex) { + console.error('ERROR: packages.json parsing error [ ' + ex.message + ' ]'); +} + +// Adding the app's packages.json as a used file for this package will get +// Meteor to watch it and reload this package when it changes +Package.onUse(function(api) { + api.add_files(['index.js', '../../packages.json'], 'server'); +}); \ No newline at end of file diff --git a/public/js/share.min.js b/public/js/share.min.js new file mode 100644 index 0000000..28d02eb --- /dev/null +++ b/public/js/share.min.js @@ -0,0 +1,3 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Share=e()}}(function(){var define,module,exports; +function getStyles(config){ return ""+config.selector+"{width:92px;height:20px;-webkit-touch-callout:none;-khtml-user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}"+config.selector+" [class*=entypo-]:before{font-family:entypo,sans-serif}"+config.selector+" label{font-size:16px;cursor:pointer;margin:0;padding:5px 10px;border-radius:5px;background:#a29baa;color:#333;-webkit-transition:all .3s ease;transition:all .3s ease}"+config.selector+" label:hover{opacity:.8}"+config.selector+" label span{text-transform:uppercase;font-size:.9em;font-family:Lato,sans-serif;font-weight:700;-webkit-font-smoothing:antialiased;padding-left:6px}"+config.selector+" .social{opacity:0;-webkit-transition:all .4s ease;transition:all .4s ease;margin-left:-15px;visibility:hidden}"+config.selector+" .social.top{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;margin-top:-80px}"+config.selector+" .social.bottom{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;margin-top:5px}"+config.selector+" .social.middle{margin-top:-34px}"+config.selector+" .social.middle.right{-webkit-transform-origin:5% 50%;-ms-transform-origin:5% 50%;transform-origin:5% 50%;margin-left:105px}"+config.selector+" .social.middle.left{-webkit-transform-origin:5% 50%;-ms-transform-origin:5% 50%;transform-origin:5% 50%}"+config.selector+" .social.right{margin-left:14px}"+config.selector+" .social.load{-webkit-transition:none!important;transition:none!important}"+config.selector+" .social.networks-1{width:60px}"+config.selector+" .social.networks-1.center,"+config.selector+" .social.networks-1.left{margin-left:14px}"+config.selector+" .social.networks-1.middle.left{margin-left:-70px}"+config.selector+" .social.networks-1 ul{width:60px}"+config.selector+" .social.networks-2{width:120px}"+config.selector+" .social.networks-2.center{margin-left:-13px}"+config.selector+" .social.networks-2.left{margin-left:-44px}"+config.selector+" .social.networks-2.middle.left{margin-left:-130px}"+config.selector+" .social.networks-2 ul{width:120px}"+config.selector+" .social.networks-3{width:180px}"+config.selector+" .social.networks-3.center{margin-left:-45px}"+config.selector+" .social.networks-3.left{margin-left:-102px}"+config.selector+" .social.networks-3.middle.left{margin-left:-190px}"+config.selector+" .social.networks-3 ul{width:180px}"+config.selector+" .social.networks-4{width:240px}"+config.selector+" .social.networks-4.center{margin-left:-75px}"+config.selector+" .social.networks-4.left{margin-left:162px}"+config.selector+" .social.networks-4.middle.left{margin-left:-250px}"+config.selector+" .social.networks-4 ul{width:240px}"+config.selector+" .social.networks-5{width:300px}"+config.selector+" .social.networks-5.center{margin-left:-105px}"+config.selector+" .social.networks-5.left{margin-left:-225px}"+config.selector+" .social.networks-5.middle.left{margin-left:-320px}"+config.selector+" .social.networks-5 ul{width:300px}"+config.selector+" .social.active{opacity:1;-webkit-transition:all .4s ease;transition:all .4s ease;visibility:visible}"+config.selector+" .social.active.top{-webkit-transform:scale(1) translateY(-10px);-ms-transform:scale(1) translateY(-10px);transform:scale(1) translateY(-10px)}"+config.selector+" .social.active.bottom{-webkit-transform:scale(1) translateY(15px);-ms-transform:scale(1) translateY(15px);transform:scale(1) translateY(15px)}"+config.selector+" .social.active.middle.right{-webkit-transform:scale(1) translateX(10px);-ms-transform:scale(1) translateX(10px);transform:scale(1) translateX(10px)}"+config.selector+" .social.active.middle.left{-webkit-transform:scale(1) translateX(-10px);-ms-transform:scale(1) translateX(-10px);transform:scale(1) translateX(-10px)}"+config.selector+" .social ul{position:relative;left:0;right:0;height:46px;color:#fff;margin:auto;padding:0;list-style:none}"+config.selector+" .social ul li{font-size:20px;cursor:pointer;width:60px;margin:0;padding:12px 0;text-align:center;float:left;display:none;height:22px;position:relative;z-index:2;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-transition:all .3s ease;transition:all .3s ease}"+config.selector+" .social ul li:hover{color:rgba(0,0,0,.5)}"+config.selector+" .social li[class*=facebook]{background:#3b5998;display:"+config.networks.facebook.display+"}"+config.selector+" .social li[class*=twitter]{background:#6cdfea;display:"+config.networks.twitter.display+"}"+config.selector+" .social li[class*=gplus]{background:#e34429;display:"+config.networks.google_plus.display+"}"+config.selector+" .social li[class*=pinterest]{background:#c5282f;display:"+config.networks.pinterest.display+"}"+config.selector+" .social li[class*=paper-plane]{background:#42c5b0;display:"+config.networks.email.display+"}"};var ShareUtils;"classList"in document.documentElement||!Object.defineProperty||"undefined"==typeof HTMLElement||Object.defineProperty(HTMLElement.prototype,"classList",{get:function(){var t,e,o;return o=function(t){return function(o){var n,i;n=e.className.split(/\s+/),i=n.indexOf(o),t(n,i,o),e.className=n.join(" ")}},e=this,t={add:o(function(t,e,o){~e||t.push(o)}),remove:o(function(t,e){~e&&t.splice(e,1)}),toggle:o(function(t,e,o){~e?t.splice(e,1):t.push(o)}),contains:function(t){return!!~e.className.split(/\s+/).indexOf(t)},item:function(t){return e.className.split(/\s+/)[t]||null}},Object.defineProperty(t,"length",{get:function(){return e.className.split(/\s+/).length}}),t}}),String.prototype.to_rfc3986=function(){var t;return t=encodeURIComponent(this),t.replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16)})},ShareUtils=function(){function t(){}return t.prototype.extend=function(t,e,o){var n,i;for(i in e)n=void 0!==t[i],n&&"object"==typeof e[i]?this.extend(t[i],e[i],o):(o||!n)&&(t[i]=e[i])},t.prototype.hide=function(t){return t.style.display="none"},t.prototype.show=function(t){return t.style.display="block"},t.prototype.has_class=function(t,e){return t.classList.contains(e)},t.prototype.add_class=function(t,e){return t.classList.add(e)},t.prototype.remove_class=function(t,e){return t.classList.remove(e)},t.prototype.is_encoded=function(t){return t=t.to_rfc3986(),decodeURIComponent(t)!==t},t.prototype.encode=function(t){return"undefined"==typeof t||this.is_encoded(t)?t:t.to_rfc3986()},t.prototype.popup=function(t,e){var o,n,i,r;return null==e&&(e={}),n={width:500,height:350},n.top=screen.height/2-n.height/2,n.left=screen.width/2-n.width/2,i=function(){var t;t=[];for(o in e)r=e[o],t.push(""+o+"="+this.encode(r));return t}.call(this).join("&"),i&&(i="?"+i),window.open(t+i,"targetWindow","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left="+n.left+",top="+n.top+",width="+n.width+",height="+n.height)},t}();var Share,__hasProp={}.hasOwnProperty,__extends=function(t,e){function o(){this.constructor=t}for(var n in e)__hasProp.call(e,n)&&(t[n]=e[n]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t};Share=function(t){function e(t,e){var o;return this.element=t,this.el={head:document.getElementsByTagName("head")[0],body:document.getElementsByTagName("body")[0]},this.config={enabled_networks:0,protocol:-1===["http","https"].indexOf(window.location.href.split(":")[0])?"https://":"//",url:window.location.href,caption:null,title:(o=document.querySelector('meta[property="og:title"]')||document.querySelector('meta[name="twitter:title"]'))?o.getAttribute("content"):(o=document.querySelector("title"))?o.innerText:void 0,image:(o=document.querySelector('meta[property="og:image"]')||document.querySelector('meta[name="twitter:image"]'))?o.getAttribute("content"):void 0,description:(o=document.querySelector('meta[property="og:description"]')||document.querySelector('meta[name="twitter:description"]')||document.querySelector('meta[name="description"]'))?o.getAttribute("content"):"",ui:{flyout:"top center",button_text:"Share",button_font:!0,icon_font:!0},networks:{google_plus:{enabled:!0,url:null},twitter:{enabled:!0,url:null,description:null},facebook:{enabled:!0,load_sdk:!0,url:null,app_id:null,title:null,caption:null,description:null,image:null},pinterest:{enabled:!0,url:null,image:null,description:null},email:{enabled:!0,title:null,description:null}}},this.setup(t,e),this}return __extends(e,t),e.prototype.setup=function(t,e){var o,n,i,r,s;for(i=document.querySelectorAll(t),this.extend(this.config,e,!0),this.set_global_configuration(),this.normalize_network_configuration(),this.config.ui.icon_font&&this.inject_icons(),this.config.ui.button_font&&this.inject_fonts(),this.config.networks.facebook.enabled&&this.config.networks.facebook.load_sdk&&this.inject_facebook_sdk(),o=r=0,s=i.length;s>r;o=++r)n=i[o],this.setup_instance(t,o)},e.prototype.setup_instance=function(t,e){var o,n,i,r,s,c,l,a,p=this;for(n=document.querySelectorAll(t)[e],this.hide(n),this.add_class(n,"sharer-"+e),n=document.querySelectorAll(t)[e],this.inject_css(n),this.inject_html(n),this.show(n),i=n.getElementsByTagName("label")[0],o=n.getElementsByClassName("social")[0],s=n.getElementsByTagName("li"),this.add_class(o,"networks-"+this.config.enabled_networks),i.addEventListener("click",function(){return p.event_toggle(o)}),p=this,a=[],e=c=0,l=s.length;l>c;e=++c)r=s[e],a.push(r.addEventListener("click",function(){return p.event_network(n,this),p.event_close(o)}));return a},e.prototype.event_toggle=function(t){return this.has_class(t,"active")?this.event_close(t):this.event_open(t)},e.prototype.event_open=function(t){return this.has_class(t,"load")&&this.remove_class(t,"load"),this.add_class(t,"active")},e.prototype.event_close=function(t){return this.remove_class(t,"active")},e.prototype.event_network=function(t,e){var o;return o=e.getAttribute("data-network"),this.hook("before",o,t),this["network_"+o](),this.hook("after",o,t)},e.prototype.open=function(){return this["public"]("open")},e.prototype.close=function(){return this["public"]("close")},e.prototype.toggle=function(){return this["public"]("toggle")},e.prototype["public"]=function(t){var e,o,n,i,r,s,c;for(s=document.querySelectorAll(this.element),c=[],o=i=0,r=s.length;r>i;o=++i)n=s[o],e=n.getElementsByClassName("social")[0],c.push(this["event_"+t](e));return c},e.prototype.network_facebook=function(){return this.config.networks.facebook.load_sdk?window.FB?FB.ui({method:"feed",name:this.config.networks.facebook.title,link:this.config.networks.facebook.url,picture:this.config.networks.facebook.image,caption:this.config.networks.facebook.caption,description:this.config.networks.facebook.description}):console.error("The Facebook JS SDK hasn't loaded yet."):this.popup("https://www.facebook.com/sharer/sharer.php",{u:this.config.networks.facebook.url})},e.prototype.network_twitter=function(){return this.popup("https://twitter.com/intent/tweet",{text:this.config.networks.twitter.description,url:this.config.networks.twitter.url})},e.prototype.network_google_plus=function(){return this.popup("https://plus.google.com/share",{url:this.config.networks.google_plus.url})},e.prototype.network_pinterest=function(){return this.popup("https://www.pinterest.com/pin/create/button",{url:this.config.networks.pinterest.url,media:this.config.networks.pinterest.image,description:this.config.networks.pinterest.description})},e.prototype.network_email=function(){return this.popup("mailto:",{subject:this.config.networks.email.title,body:this.config.networks.email.description})},e.prototype.inject_icons=function(){return this.inject_stylesheet("https://www.sharebutton.co/fonts/v2/entypo.min.css")},e.prototype.inject_fonts=function(){return this.inject_stylesheet("http://fonts.googleapis.com/css?family=Lato:900&text="+this.config.ui.button_text)},e.prototype.inject_stylesheet=function(t){var e;return this.el.head.querySelector('link[href="'+t+'"]')?void 0:(e=document.createElement("link"),e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),this.el.head.appendChild(e))},e.prototype.inject_css=function(t){var e,o,n,i;return n="."+t.getAttribute("class").split(" ").join("."),this.el.head.querySelector("meta[name='sharer"+n+"']")?void 0:(this.config.selector=n,e=getStyles(this.config),i=document.createElement("style"),i.type="text/css",i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e)),this.el.head.appendChild(i),delete this.config.selector,o=document.createElement("meta"),o.setAttribute("name","sharer"+n),this.el.head.appendChild(o))},e.prototype.inject_html=function(t){return t.innerHTML="
"},e.prototype.inject_facebook_sdk=function(){var t,e;return window.FB||!this.config.networks.facebook.app_id||this.el.body.querySelector("#fb-root")?void 0:(e=document.createElement("script"),e.text="window.fbAsyncInit=function(){FB.init({appId:'"+this.config.networks.facebook.app_id+"',status:true,xfbml:true})};(function(e,t,n){var r,i=e.getElementsByTagName(t)[0];if(e.getElementById(n)){return}r=e.createElement(t);r.id=n;r.src='"+this.config.protocol+"connect.facebook.net/en_US/all.js';i.parentNode.insertBefore(r,i)})(document,'script','facebook-jssdk')",t=document.createElement("div"),t.id="fb-root",this.el.body.appendChild(t),this.el.body.appendChild(e))},e.prototype.hook=function(t,e,o){var n,i;n=this.config.networks[e][t],"function"==typeof n&&(i=n.call(this.config.networks[e],o),void 0!==i&&(i=this.normalize_filter_config_updates(i),this.extend(this.config.networks[e],i,!0),this.normalize_network_configuration()))},e.prototype.set_global_configuration=function(){var t,e,o,n,i,r;i=this.config.networks,r=[];for(e in i){n=i[e];for(o in n)null==this.config.networks[e][o]&&(this.config.networks[e][o]=this.config[o]);this.config.networks[e].enabled?(t="block",this.config.enabled_networks+=1):t="none",r.push(this.config.networks[e].display=t)}return r},e.prototype.normalize_network_configuration=function(){return this.config.networks.facebook.app_id||(this.config.networks.facebook.load_sdk=!1),this.is_encoded(this.config.networks.twitter.description)||(this.config.networks.twitter.description=encodeURIComponent(this.config.networks.twitter.description)),"number"==typeof this.config.networks.facebook.app_id?this.config.networks.facebook.app_id=this.config.networks.facebook.app_id.toString():void 0},e.prototype.normalize_filter_config_updates=function(t){return this.config.networks.facebook.app_id!==t.app_id&&(console.warn("You are unable to change the Facebook app_id after the button has been initialized. Please update your Facebook filters accordingly."),delete t.app_id),this.config.networks.facebook.load_sdk!==t.load_sdk&&(console.warn("You are unable to change the Facebook load_sdk option after the button has been initialized. Please update your Facebook filters accordingly."),delete t.app_id),t},e}(ShareUtils); return Share; +}); \ No newline at end of file diff --git a/server/flickr.js b/server/flickr.js new file mode 100644 index 0000000..2ab1fe5 --- /dev/null +++ b/server/flickr.js @@ -0,0 +1,61 @@ +/** + This is a simple wrapper for the npm package flickrapi + (https://www.npmjs.com/package/flickrapi), so it can be used + in a Meteor context. It provides a few convenience methods for returning + random photos (combined with a link to the photo on Flickr) of a + specified search term. + + Inspired by: + http://meteorcapture.com/publishing-data-from-an-external-api/ + + Developer notes: + + var photo = + { id: '16287638134', + owner: '130080108@N02', + secret: 'd3ff2ffc58', + server: '7281', + farm: 8, + title: 'Landscape 5 By: Anton Antonov', + ispublic: 1, + isfriend: 0, + isfamily: 0 } ] } +*/ + +// Contains the API object +var flickr = { + call: function(method, args) { + var params = { + api_key: Meteor.settings['flickr_api_key'], + method: 'flickr.' + method, + nojsoncallback: 1, + format: 'json' + }; + for (key in args) { + params[key] = args[key]; + } + return HTTP.call('GET', 'https://api.flickr.com/services/rest/', {'params': params}); + } +}; + +// If key and secret aren't set, don't do anything +if (Meteor.settings['flickr_api_key'] && Meteor.settings['flickr_api_secret']) { + + // Add methods for searching etc + Meteor.methods({ + 'flickrSearchPhotos': function(text) { + if (text.length < 2) { + throw new Meteor.Error('photo-search', 'Unable to find photos with text: ', text); + } + var response = flickr.call('photos.search', { + 'text': text + }); + + if (response.data) { + return response.data; + } else { + throw new Meteor.Error('photo-search', 'Unable to find photos with text: ', text); + } + } + }); +} \ No newline at end of file diff --git a/server/server.js b/server/server.js new file mode 100644 index 0000000..00bd769 --- /dev/null +++ b/server/server.js @@ -0,0 +1,27 @@ +Meteor.startup(function() { +}); + +Meteor.publish("haikus", function() { + return Haikus.find({}); +}); +Meteor.publish("comments", function() { + return Comments.find(); +}); +Meteor.publish("likes", function() { + return Likes.find(); +}); + +Meteor.publish('flickr', function(){ + return Flickr.find(); +}); + +Meteor.publish("users", function () { + return Meteor.users.find({},{fields: {'_id': 1, 'username': 1, 'profile':1,'userDescription':1}}); +}); + + +Meteor.users.deny({ + update: function() { + return true; + } +}); \ No newline at end of file