diff --git a/.gitignore b/.gitignore
index 60d9092f91..6b84cb7df8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,7 +10,7 @@ lib-cov
.floo
.flooignore
builtAssets/
-
+pm2.js
*.env
pids
logs
diff --git a/README.md b/README.md
index 9770de3ebc..8e6742b074 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
+
+
[](https://waffle.io/freecodecamp/freecodecamp/metrics)
-[](https://waffle.io/FreeCodeCamp/freecodecamp)
-
+[](https://gitter.im/freecodecamp/freecodecamp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Welcome to Free Code Camp's open source codebase!
=======================
@@ -17,7 +18,7 @@ Our campers (students) start by working through our free, self-paced, browser-ba
80% of our campers are over 25, and nearly a fifth of our campers are women.
-This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
+This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
[Join our community](http://www.freecodecamp.com/signin)!
@@ -27,7 +28,7 @@ Contributing
We welcome pull requests from Free Code Camp campers (our students) and seasoned JavaScript developers alike! Follow these steps to contribute:
1. Check our [public Waffle Board](https://waffle.io/freecodecamp/freecodecamp).
-2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Slack](http://freecodecamp.slack.com).
+2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp)
3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches))
5. Name the branch something like `user-xxx` where user is your username and xxx is the issue number you are addressing.
diff --git a/common/models/User-Identity.json b/common/models/User-Identity.json
index d63e5c0af3..79c2192f1c 100644
--- a/common/models/User-Identity.json
+++ b/common/models/User-Identity.json
@@ -11,6 +11,13 @@
"foreignKey": "userId"
}
},
- "acls": [],
+ "acls": [
+ {
+ "accessType": "*",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "DENY"
+ }
+ ],
"methods": []
}
diff --git a/common/models/bonfire.json b/common/models/bonfire.json
index ae5e5db32a..859f0196ed 100644
--- a/common/models/bonfire.json
+++ b/common/models/bonfire.json
@@ -36,7 +36,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
}
],
diff --git a/common/models/challenge.json b/common/models/challenge.json
index dfc8c9c4a9..f270e7f70b 100644
--- a/common/models/challenge.json
+++ b/common/models/challenge.json
@@ -72,7 +72,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
}
],
diff --git a/common/models/comment.json b/common/models/comment.json
index ada3b000d6..ec29a05c98 100644
--- a/common/models/comment.json
+++ b/common/models/comment.json
@@ -22,14 +22,15 @@
},
"rank": {
"type": "number",
- "default": "-Infinity"
+ "default": 0
},
"upvotes": {
"type": "array",
"default": []
},
"author": {
- "type": {}
+ "type": {},
+ "default": {}
},
"comments": {
"type": "array",
@@ -49,6 +50,12 @@
"principalId": "$everyone",
"permission": "DENY"
},
+ {
+ "accessType": "READ",
+ "principalType": "ROLE",
+ "principalId": "$everyone",
+ "permission": "ALLOW"
+ },
{
"accessType": "EXECUTE",
"principalType": "ROLE",
diff --git a/common/models/field-guide.json b/common/models/field-guide.json
index b8e734247c..be3ae99a25 100644
--- a/common/models/field-guide.json
+++ b/common/models/field-guide.json
@@ -29,7 +29,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
}
],
diff --git a/common/models/job.json b/common/models/job.json
index 30f981d4df..83d50ebc7b 100644
--- a/common/models/job.json
+++ b/common/models/job.json
@@ -32,7 +32,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
}
],
diff --git a/common/models/nonprofit.json b/common/models/nonprofit.json
index 2cfad23d66..738c43e9ad 100644
--- a/common/models/nonprofit.json
+++ b/common/models/nonprofit.json
@@ -8,21 +8,12 @@
"type": "string",
"unique": true
},
- "requestedDeliverables": {
- "type": "array"
- },
"whatDoesNonprofitDo": {
"type": "string"
},
"websiteLink": {
"type": "string"
},
- "stakeholderName": {
- "type": "string"
- },
- "stakeholderEmail": {
- "type": "string"
- },
"endUser": {
"type": "string"
},
@@ -41,11 +32,8 @@
"estimatedHours": {
"type": "number"
},
- "interestedCampers": {
- "type": []
- },
- "confirmedCampers": {
- "type": []
+ "moneySaved": {
+ "type": "number"
},
"currentStatus": {
"type": "string"
@@ -63,7 +51,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
}
],
diff --git a/common/models/story.json b/common/models/story.json
index bdd86a996b..4b50e3eed4 100644
--- a/common/models/story.json
+++ b/common/models/story.json
@@ -69,7 +69,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
- "principalId": "$authenticated",
+ "principalId": "$everyone",
"permission": "ALLOW"
},
{
diff --git a/common/models/user.json b/common/models/user.json
index a7caad6227..0254ff8407 100644
--- a/common/models/user.json
+++ b/common/models/user.json
@@ -134,7 +134,8 @@
"type": "string"
},
"uncompletedBonfires": {
- "type": "array"
+ "type": "array",
+ "default": []
},
"completedBonfires": {
"type": [
diff --git a/config/secrets.js b/config/secrets.js
index 2ea3cdef28..ed369d9766 100644
--- a/config/secrets.js
+++ b/config/secrets.js
@@ -13,10 +13,6 @@ module.exports = {
key: process.env.BLOGGER_KEY
},
- slack: {
- key: process.env.SLACK_KEY
- },
-
mandrill: {
user: process.env.MANDRILL_USER,
password: process.env.MANDRILL_PASSWORD
diff --git a/public/js/main_0.0.2.js b/public/js/main_0.0.3.js
similarity index 96%
rename from public/js/main_0.0.2.js
rename to public/js/main_0.0.3.js
index 1b41b9066b..20152c48f5 100644
--- a/public/js/main_0.0.2.js
+++ b/public/js/main_0.0.3.js
@@ -30,7 +30,7 @@ $(document).ready(function() {
},
function(res) {
if (res) {
- window.open('https://freecodecamp.slack.com/messages/help/', '_blank')
+ window.open('https://gitter.im/FreeCodeCamp/Help', '_blank')
}
}
);
@@ -48,7 +48,7 @@ $(document).ready(function() {
},
function(res) {
if (res) {
- window.open('https://freecodecamp.slack.com/messages/help/', '_blank')
+ window.open('https://gitter.im/FreeCodeCamp/Help', '_blank')
}
}
);
@@ -71,7 +71,7 @@ $(document).ready(function() {
},
function(res) {
if (res) {
- window.open('https://freecodecamp.slack.com/messages/letspair/', '_blank')
+ window.open('https://gitter.im/FreeCodeCamp/LetsPair', '_blank')
}
}
);
@@ -150,10 +150,6 @@ $(document).ready(function() {
$('#help-modal').modal('show');
});
- $('#trigger-help-editorless-modal').on('click', function() {
- $('#help-editorless-modal').modal('show');
- });
-
$('#trigger-issue-modal').on('click', function() {
$('#issue-modal').modal('show');
});
@@ -323,15 +319,13 @@ $(document).ready(function() {
.fail(function (xhr, textStatus, errorThrown) {
$('#story-submit').bind('click', storySubmitButtonHandler);
})
- .done(function (data, textStatus, xhr) {
- window.location = '/stories/' + JSON.parse(data).storyLink;
+ .done(function(data, textStatus, xhr) {
+ window.location = '/stories/' + data.storyLink;
});
-
};
$('#story-submit').on('click', storySubmitButtonHandler);
-
var commentSubmitButtonHandler = function commentSubmitButtonHandler() {
$('#comment-button').unbind('click');
var data = $('#comment-box').val();
diff --git a/seed/challenges/advanced-bonfires.json b/seed/challenges/advanced-bonfires.json
index 978ebe81ce..58f6602791 100644
--- a/seed/challenges/advanced-bonfires.json
+++ b/seed/challenges/advanced-bonfires.json
@@ -81,7 +81,7 @@
"sym([1, 2, 3], [5, 2, 1, 4]);"
],
"tests": [
- "expect(sym([1, 2, 3], [5, 2, 1, 4])).to.eqls([3, 5, 4])",
+ "expect(sym([1, 2, 3], [5, 2, 1, 4])).to.equal([3, 5, 4]);",
"assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays');",
"assert.deepEqual(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'should return an array of unique values');",
"assert.deepEqual(sym([1, 1]), [1], 'should return an array of unique values');"
diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json
index ae9b0b571a..bc75adb4ac 100644
--- a/seed/challenges/basic-bonfires.json
+++ b/seed/challenges/basic-bonfires.json
@@ -14,7 +14,7 @@
"Pair Programming is where two people code together on the same computer. It is an efficient way to collaborate, and widely practiced at software companies. Pair Programming is one of the core concepts of \"Agile\" Software Development, which you will hear more about later.",
"Many people use Skype or Google Hangouts to pair program, but if you talk with professional software engineers, they will tell you that it's not really pair programming unless both people have the ability to use the keyboard and mouse.",
"The most popular tool for pair programming is Screen Hero. You can download Screen Hero for Mac or Windows. Create your new user account from within the app.",
- "We have a special chat room for people ready to pair program. Go to our http://freecodecamp.slack.com/messages/letspair and type \"Hello Pair Programmers!\"",
+ "We have a special chat room for people ready to pair program. Go to our LetsPair chatroom on gitter and type \"Hello Pair Programmers!\"",
"If someone is available, they will be your \"pair\" - the person you pair programming with.",
"If no one gets back to you in the first few minutes, don't worry. There will be lots of opportunities to pair program in the future.",
"If someone does get back to you, private message them and ask for the email address they used to register Screen Hero.",
diff --git a/seed/challenges/basic-html5-and-css.json b/seed/challenges/basic-html5-and-css.json
index fb8c4aa952..143e92cab5 100644
--- a/seed/challenges/basic-html5-and-css.json
+++ b/seed/challenges/basic-html5-and-css.json
@@ -1678,7 +1678,7 @@
"You can create one like this:
<input type='text'>
. Note that input
elements are self-closing."
],
"tests": [
- "assert($('input').length > 0, 'Your app should have an text field input element.')"
+ "assert($('input').length > 0, 'Your app should have a text field input element.')"
],
"challengeSeed": [
"",
diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json
index 41a7229731..2fb852ade8 100644
--- a/seed/challenges/bootstrap.json
+++ b/seed/challenges/bootstrap.json
@@ -8,7 +8,7 @@
"dashedName": "waypoint-mobile-responsive-images",
"difficulty": 0.047,
"description": [
- "Now let's go back to our Cat Photo App. This time, we'll style it using the popular Twitter Bootstrap responsive CSS framework. First, add a new image with the src
attribute of \"http://bit.ly/fcc-kittens2\", and add the \"img-responsive\" Bootstrap class to that image.",
+ "Now let's go back to our Cat Photo App. This time, we'll style it using the popular Bootstrap responsive CSS framework. First, add a new image with the src
attribute of \"http://bit.ly/fcc-kittens2\", and add the \"img-responsive\" Bootstrap class to that image.",
"It would be great if the image could be exactly the width of our phone's screen.",
"Fortunately, we have access to a Responsive CSS Framework called Bootstrap. You can add Bootstrap to any app just by including it with <link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'/>
at the top of your HTML. But we've gone ahead and automatically added it to your Cat Photo App for you.",
"Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name Responsive Design
.",
diff --git a/seed/challenges/get-set-for-free-code-camp.json b/seed/challenges/get-set-for-free-code-camp.json
index b576bad9c9..a657759d08 100644
--- a/seed/challenges/get-set-for-free-code-camp.json
+++ b/seed/challenges/get-set-for-free-code-camp.json
@@ -56,15 +56,18 @@
"name": "Waypoint: Join Our Chat Room",
"dashedName": "waypoint-join-our-chat-room",
"difficulty": 0.002,
- "challengeSeed": ["131321596"],
+ "challengeSeed": ["131574135"],
"description": [
"Now we're going to join the Free Code Camp chat room. You can come here any time of day to hang out, ask questions, or find another camper to pair program with.",
"Create an account with GitHub here: https://github.com/join.",
"Click the pixel art in the upper right hand corner of GitHub, then choose settings. Upload a picture of yourself. A picture of your face works best. This is how people will see you in our chat rooms, so put your best foot forward. You can add your city and your personal website if you have one.",
- "Now follow this link to enter our Welcome chat room: https://gitter.im/FreeCodeCamp/welcome.",
- "Once you're in our Welcome chat room, introduce yourself by saying : \"Hello world!\".",
+ "Go to Free Code Camp's open-source repository: https://github.com/freecodecamp/freecodecamp.",
+ "You can \"star\" this repository by clicking the star button in the upper right hand corner.",
+ "Later, you'll be able to fork this repository if you'd like to contribute to our open source codebase.",
+ "Join our main chat room: https://gitter.im/FreeCodeCamp/FreeCodeCamp.",
+ "Once you're in our chat room, introduce yourself by saying : \"Hello world!\".",
"Tell your fellow campers how you found Free Code Camp. Also tell us why you want to learn to code.",
- "This is the best room for new campers, but feel free to join other chat rooms as well. Our main chat room: https://gitter.im/FreeCodeCamp/FreeCodeCamp.",
+ "We have a busy chat room, so be sure to configure your notification settings in the top right corner.",
"Keep the chat room open while you work through the other challenges. That way you ask for help if you get stuck on a challenge. You can also socialize when you feel like taking a break.",
"You can also download a desktop or mobile chat application here: https://gitter.im/apps",
"You can also access this chat room by clicking the \"Chat\" button in the upper right hand corner.",
@@ -297,7 +300,7 @@
"challengeSeed": ["127358841"],
"description": [
"One of the best ways to stay motivated when learning to code is to hang out with other campers.",
- "Slack and Camper News are great ways to communicate with other campers, but there's no substitute for meeting people in-person.",
+ "Gitter and Camper News are great ways to communicate with other campers, but there's no substitute for meeting people in-person.",
"The easiest way to meet other campers in your city is to join your city's Facebook Group. Click here to view our growing list of local groups.",
"Click the link to your city, then, once Facebook loads, click \"Join group\".",
"Our local groups are new, so if you don't see your city on this list, you should follow the directions to create a Facebook group for your city.",
@@ -316,7 +319,7 @@
"nameEs": "Waypoint: Encuentrate con otros Campers en tu Ciudad",
"descriptionEs": [
"Una de las mejores maneras de mantenerte motivado cuando estás aprendiendo a programar es pasar el rato con otros campers.",
- "Slack y Noticias de Campers son una muy buena forma de comunicarte con otros campers, pero no hay ningún substituto para conocerlos en persona.",
+ "Gitter y Noticias de Campers son una muy buena forma de comunicarte con otros campers, pero no hay ningún substituto para conocerlos en persona.",
"La forma más fácil de encontrarte con otros campers en tu ciudad es unirte al grupo de Facebook de tu ciudad o país. Dale click a here para ver la lista de grupos locales.",
"Dale click al link de tu ciudad o país y una vez que Facebook cargue, dale click a \"Join group\".",
"Nuestros grupos locales son pocos, asi que en caso no veas tu ciudad o país en la lista, solamente sigue las instrucciones para crear un grupo de Facebook para ello.",
@@ -339,17 +342,48 @@
]
},
{
+ "_id": "bd7126d8c431eddfaeb5bd3e",
+ "name": "Waypoint: Add Free Code Camp to your LinkedIn Profile",
+ "difficulty": 0.008,
+ "challengeSeed": ["131574134"],
+ "description": [
+ "LinkedIn is a critical tool for your job search later on.",
+ "Add Free Code Camp to your LinkedIn profile by going to https://www.linkedin.com/profile/edit-education?school=Free+Code+Camp.",
+ "Estimate your dates. Keep in mind that Free Code Camp is a rigorous 1,600 hour program, and will probably take at least a year to complete.",
+ "In the \"Degree\" section, type \"Full Stack Web Development\".",
+ "In the \"Field of study\" section, type \"Computer Software Engineering\".",
+ "Click the \"Save Changes\" button.",
+ "Be sure to add your key word skills to LinkedIn's skills section as you learn them, such as HTML, jQuery, Linux and Node.js.",
+ "You can expand your LinkedIn network by inviting friends you meet through Free Code Camp to connect with you on LinkedIn.",
+ "Make your LinkedIn profile as complete as possible. Unlike other social networks, with LinkedIn, it's perfectly fine if you don't want to add a photo.",
+ "Let's keep moving. We're almost ready to start coding!"
+ ],
+ "challengeType": 2,
+ "tests": [],
+ "nameCn": "",
+ "descriptionCn": [],
+ "nameFr": "",
+ "descriptionFr": [],
+ "nameRu": "",
+ "descriptionRu": [],
+ "nameEs": "",
+ "descriptionEs": [],
+ "namePt": "",
+ "descriptionPt": []
+ },
+ {
+ "_id": "bd7137d8c441eddfaeb5bdef",
"id": "bd7137d8c441eddfaeb5bdef",
"name": "Waypoint: Get Help the Hacker Way with RSAP",
"dashedName": "waypoint-get-help-the-hacker-way-with-rsap",
- "difficulty": 0.008,
+ "difficulty": 0.009,
"challengeSeed": ["125407432"],
"description": [
"Let's cover one last thing before you start working through our lessons: how to get help.",
"Any time you get stuck or don't know what to do next, follow this simple algorithm (procedure): RSAP (Read, Search, Ask, Post).",
"First, R - Read the documentation or error message. A key skill that good coders have is the ability to interpret and then follow instructions.",
"Next, S - Search Google. Good Google queries take a lot of practice. When you search Google, you usually want to include the language or framework you're using. You also want to limit the results to a recent period.",
- "Then, if you still haven't found an answer to your question, A - Ask your friends. If you have trouble, you can ask your fellow campers. We have a special chat room specifically for getting help with tools you learn through these Free Code Camp Challenges. Go to https://freecodecamp.slack.com/messages/help/. Keep this chat open while you work on the remaining challenges.",
+ "Then, if you still haven't found an answer to your question, A - Ask your friends. If you have trouble, you can ask your fellow campers. We have a special chat room specifically for getting help with tools you learn through these Free Code Camp Challenges. Go to https://gitter.im/FreeCodeCamp/Help. Keep this chat open while you work on the remaining challenges.",
"Finally, P - Post on Stack Overflow. Before you attempt to do this, read Stack Overflow's guide to asking good questions: http://stackoverflow.com/help/how-to-ask.",
"Here's our detailed field guide on getting help: http://freecodecamp.com/field-guide/how-do-i-get-help-when-i-get-stuck.",
"Now you have a clear algorithm to follow when you need help! Let's start coding! Move on to your next challenge."
@@ -368,7 +402,7 @@
"Cualquier momento en el que te atasques o no sepas que hacer, sigue este simple algoritmo (procedimiento): RSAP (Read, Search, Ask, Post). Que en español vendría a ser Lee, Busca, Pregunta, Publica.",
"Primero, Lee - Lee la documentación o el mensaje de error. El punto fuerte de un buen programador es la habilidad de interpretar y seguir instrucciones.",
"Luego, Busca - Busca en Google. Buenas búsquedas o queries requieren bastante práctica. Cuando búsques en Google, idealmente tienes que incluir el lenguaje o framework que estés usando. También tendrás que limitar los resultados de búsqueda a un periodo reciente.",
- "Ahora, en caso no hayas encontrado la respuesta a tu pregunta, Pregunta - Pregunta a tus amigos. En caso estes en problemas, puedes preguntar a otros campers. Tenemos una sala de chat especificamente para obtener ayuda sobre las herramientas que utilizamos en los desafíos de Free Code Camp. Ingresa a https://freecodecamp.slack.com/messages/help/. Mantén este chat abierto mientras trabajas en los desafíos subsiguientes.",
+ "Ahora, en caso no hayas encontrado la respuesta a tu pregunta, Pregunta - Pregunta a tus amigos. En caso estes en problemas, puedes preguntar a otros campers. Tenemos una sala de chat especificamente para obtener ayuda sobre las herramientas que utilizamos en los desafíos de Free Code Camp. Ingresa a https://gitter.im/FreeCodeCamp/Help. Mantén este chat abierto mientras trabajas en los desafíos subsiguientes.",
"Finalmente, Publica - Publica tu pregunta en Stack Overflow. Antes de hacer esto lee la guía de Stack Overflow para publicar buenas preguntas: http://stackoverflow.com/help/how-to-ask. Tendrás que hacerlo en inglés, en caso no sepas como, pide que te ayuden a traducir tu pregunta en el canal #espanol de Slack.",
"Aquí está nuestra guia detallada en como obtener ayuda: http://freecodecamp.com/field-guide/how-do-i-get-help-when-i-get-stuck.",
"Ahora que tienes en claro el procedimiento a seguir cuando necesites ayuda. ¡Empecémos a programar! Continua con el siguiente desafío."
diff --git a/seed/field-guides.json b/seed/field-guides.json
index 9d3e906d16..92d9757116 100644
--- a/seed/field-guides.json
+++ b/seed/field-guides.json
@@ -225,7 +225,7 @@
"
This is the most time-efficient way to handle being stuck, and it's the most respectful of other people's time, too.
", "Most of the time, you'll solve your problem after just one or two steps of this algorithm.
", - "We have a special chat room just for getting help: https://freecodecamp.slack.com/messages/help/
", + "We have a special chat room just for getting help: https://gitter.im/freecodecamp/help/
", "Also, if you need to post on Stack Overflow, be sure to read their guide to asking good questions: http://stackoverflow.com/help/how-to-ask.
", "Learning to code is hard. But it's a lot easier if you ask for help when you need it!
", "" @@ -279,7 +279,7 @@ "", "
It's notoriously difficult to estimate how long building software projects will take, so feel free to ask our volunteer team for help.
", - "You'll continue to meet with your stakeholder at least twice a month in your project's Slack channel.
", - "You should also ask questions in your project's Slack channel as they come up throughout the week, and your stakeholder can answer them asynchronously.
", + "You'll continue to meet with your stakeholder at least twice a month in your project's Gitter or Slack channel.
", + "You should also ask questions in your project's Gitter or Slack channel as they come up throughout the week, and your stakeholder can answer them asynchronously.
", "Getting \"blocked\" on a task can take away your sense of forward momentum, so be sure to proactively seek answers to any ambiguities you encounter.
", "Ultimately, the project will be considered complete once both the stakeholder's needs have been met, and you and your pair are happy with the project. Then you can add it to your portfolio!
", "Here are our recommended ways of collaborating:
", "", "
Free Code Camp should be a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, national origin, or religion (or lack thereof).
", - "We do not tolerate harassment of campers in any form, anywhere on Free Code Camp's online media (Slack, Twitch, etc.) or during pair programming. Harassment includes sexual language and imagery, deliberate intimidation, stalking, unwelcome sexual attention, libel, and any malicious hacking or social engineering.
", + "We do not tolerate harassment of campers in any form, anywhere on Free Code Camp's online media (Gitter, Twitch, etc.) or during pair programming. Harassment includes sexual language and imagery, deliberate intimidation, stalking, unwelcome sexual attention, libel, and any malicious hacking or social engineering.
", "If a camper engages in harassing behavior, our team will take any action we deem appropriate, up to and including banning them from Free Code Camp.
", - "We want everyone to feel safe and respected. If you are being harassed or notice that someone else is being harassed, say something! Message @quincylarson, @terakilobyte and @codenonprofit in Slack (preferably with a screen shot of the offending language) so we can take fast action.
", + "We want everyone to feel safe and respected. If you are being harassed or notice that someone else is being harassed, say something! Message @quincylarson, @terakilobyte and @codenonprofit on Gitter (preferably with a screen shot of the offending language) so we can take fast action.
", "If you have questions about this code of conduct, email us at team@freecodecamp.com.
", "" ] @@ -777,10 +777,10 @@ "", "
We strive to be helpful and transparent in everything we do. We'll do what we can to help you share our community with your audience.
", @@ -838,7 +838,7 @@ "Contributing to our field guide is a great way to establish your history on GitHub, add to your portfolio, and help other campers. If you have a question about JavaScript or programming in general that you'd like us to add to the field guide, here are two ways to get it into the guide:
", "", "
Our translation effort is driven by bilingual campers like you.", - "
If you're able to help us, you can join our Trello board by sending @quincylarson your email address in Slack.
", + "If you're able to help us, you can join our Trello board by sending @quincylarson your email address on Gitter.
", "Translation is an all-or-nothing proposal.", "
We won't be able to add new languages to Free Code Camp until all of our challenges are translated into that language.
", "In addition to translating these initially, we'll also need to maintain the translation as the challenges are gradually updated.
", - "If you're able to help us, you can join our Trello board by sending @quincylarson your email address in Slack.
", + "If you're able to help us, you can join our Trello board by sending @quincylarson your email address on Gitter.
", "" ] }, diff --git a/seed/loopbackMigration.js b/seed/loopbackMigration.js index 02dd993b9c..f6b98b8b7b 100644 --- a/seed/loopbackMigration.js +++ b/seed/loopbackMigration.js @@ -7,6 +7,7 @@ var Rx = require('rx'), secrets = require('../config/secrets'); var MongoClient = mongodb.MongoClient; +Rx.config.longStackSupport = true; var providers = [ 'facebook', @@ -160,28 +161,45 @@ var storyCount = dbObservable }) .count(); +var commentCount = dbObservable + .flatMap(function(db) { + return createQuery(db, 'comments', {}); + }) + .bufferWithCount(20) + .withLatestFrom(dbObservable, function(comments, db) { + return { + comments: comments, + db: db + }; + }) + .flatMap(function(dats) { + return insertMany(dats.db, 'comment', dats.comments, { w: 1 }); + }) + .count(); + Rx.Observable.combineLatest( userIdentityCount, userSavesCount, storyCount, - function(userIdentCount, userCount, storyCount) { + commentCount, + function(userIdentCount, userCount, storyCount, commentCount) { return { userIdentCount: userIdentCount * 20, userCount: userCount * 20, - storyCount: storyCount * 20 + storyCount: storyCount * 20, + commentCount: commentCount * 20 }; }) .subscribe( - function(countObj) { - console.log('next'); - count = countObj; - }, - function(err) { - console.error('an error occured', err, err.stack); - }, - function() { - - console.log('finished with ', count); - process.exit(0); - } -); + function(countObj) { + console.log('next'); + count = countObj; + }, + function(err) { + console.error('an error occured', err, err.stack); + }, + function() { + console.log('finished with ', count); + process.exit(0); + } + ); diff --git a/seed/nonprofits.json b/seed/nonprofits.json index 23ba9af652..2b862070c0 100644 --- a/seed/nonprofits.json +++ b/seed/nonprofits.json @@ -1,13 +1,6 @@ [ { "id": "bd7157d8c441cbafaeb5bdef", - "requestedDeliverables": [ - "website", - "donor", - "inventory", - "volunteer", - "form" - ], "whatDoesNonprofitDo": "We help the many less-fortunate Jewish families in our community, by providing them with nutritious food and energy to grow, learn, work, and give them hope for a better and brighter future.", "websiteLink": "http://chasdeikaduri.org/", "name": "Chasdei Kaduri", @@ -21,17 +14,13 @@ ], "projectDescription": "Campers will create a system will integrate the food inventory, donor and delivery driver management systems as well as replace the current application system with a custom form solution. System will include a more streamlined operations management, with user printable lists of inventory, drivers, and deliveries.", "logoUrl": "https://trello-attachments.s3.amazonaws.com/54c7e02f2c173c37015b2f36/604x309/00580a0567a4b3afda29d52b09e7e829/rQQ6zwq31Uya8ie9QHC-MlvfXxqftm9UPPe524JUhmwSEaZjQ7oL7U1tVoHLUj-gVUwM-7uzBGFsAXD_A_cx_JyAZP4Td-GMBJ-AebJNRAQP0m0v253eKMkURp63aG4%3Ds0-d-e1-ft.png", - "imageUrl": "http://chasdeikaduri.org/images/523455_516325865106850_1885515210_n.jpg", - "estimatedHours": 200, - "interestedCampers": [], - "confirmedCampers": [], - "currentStatus": "completed" + "imageUrl": "https://pbs.twimg.com/media/B3d6B8PIYAAa6QL.jpg", + "estimatedHours": 300, + "currentStatus": "completed", + "moneySaved": 60000 }, { "id": "bd7158d8c464cbafaeb4bdef", - "requestedDeliverables": [ - "other" - ], "whatDoesNonprofitDo": "We connect simple technology with last mile communities to reduce poverty.", "websiteLink": "http://kopernik.info/", "name": "Kopernik", @@ -43,13 +32,11 @@ "logoUrl": "https://trello-attachments.s3.amazonaws.com/54d29f1e4c726fd765fa87ef/54d29f6388812dd367a243ab/x/018d9d3be5439870c56cccba5b3aa8bf/kopernik-logo-global.png", "imageUrl": "http://kopernik.info/sites/default/files/updates/Presenting_the_low_carbon_t.jpg", "estimatedHours": 100, - "currentStatus": "completed" + "currentStatus": "completed", + "moneySaved": 20000 }, { "id": "bd1326d9c245cbafaeb4bdef", - "requestedDeliverables": [ - "website" - ], "whatDoesNonprofitDo": "We distribute biodegradable toothbrushes globally to children in need.", "websiteLink": "http://www.operationbrush.org/", "name": "Operation Brush", @@ -61,15 +48,11 @@ "logoUrl": "https://trello-attachments.s3.amazonaws.com/54d9810307b159a4d9027aa2/54d981bfe5eb145560fbb769/x/cf7f318bfe4aee631b0d0eeef272225c/logo.png", "imageUrl": "http://www.operationbrush.org/images/temp/hands1.png", "estimatedHours": 100, - "interestedCampers": [], - "confirmedCampers": [], - "currentStatus": "completed" + "currentStatus": "completed", + "moneySaved": 20000 }, { "id": "bd1325d8c464cbafaeb5bdef", - "requestedDeliverables": [ - "community" - ], "whatDoesNonprofitDo": "We are the largest roller derby league in the world with around 250 adults and 150 junior skater members plus 500+ volunteers.", "websiteLink": "http://www.rosecityrollers.com/about/our-charities/", "name": "Rose City Rollers", @@ -81,13 +64,11 @@ "logoUrl": "https://trello-attachments.s3.amazonaws.com/54c1daf2d72d8eb868910b60/54c1dd4ecffcb09fc52b68a1/x/a8148f08769b449217e433bab8f39ddd/RCR-color.jpg", "imageUrl": "http://www.rosecityrollers.com/wp-content/uploads/2015/01/BZ7_5923-X3-675x375.jpg", "estimatedHours": 200, - "currentStatus": "started" + "currentStatus": "started", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb6bde1", - "requestedDeliverables": [ - "website" - ], "whatDoesNonprofitDo": "We provide urgently needed pediatric heart surgery and follow-up care for indigent children from developing countries", "websiteLink": "http://www.saveachildsheart.com/global/young-leadership-program/", "name": "Save a Child's Heart", @@ -98,14 +79,12 @@ "projectDescription": "Campers will create a single page fundraising website. In exchange for a donation, a user can customize a graphical 'heart' in someone's name or anonymously. The page will display all of the hearts on a 'wall of hearts.'", "logoUrl": "https://trello-attachments.s3.amazonaws.com/548b36629137780091a973cc/666x666/6c7a366ffb659649f6377d4a431687cd/country-logos-1-300dpi.jpg", "imageUrl": "http://www.saveachildsheart.com/wp-content/uploads/2013/10/7.2.5_Internation_Photograohy_Exhibition.jpg", - "estimatedHours": 100, - "currentStatus": "completed" + "estimatedHours": 200, + "currentStatus": "completed", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb4bdef", - "requestedDeliverables": [ - "website" - ], "whatDoesNonprofitDo": "We empower youth with technology by providing age appropriate resources and education.", "websiteLink": "http://savvycyberkids.org/", "name": "Savvy Cyber Kids", @@ -117,13 +96,11 @@ "logoUrl": "https://trello-attachments.s3.amazonaws.com/54ee3c7bf205562680177b59/218x190/1dc460de4edc9fdd4b481b24e93cfb23/logo.png", "imageUrl": "http://www.privatewifi.com/wp-content/uploads/2014/10/Halpert.jpg", "estimatedHours": 200, - "currentStatus": "started" + "currentStatus": "started", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb7bcef", - "requestedDeliverables": [ - "other" - ], "whatDoesNonprofitDo": "We bring a new edge to arts and medicine in the Bay Area through powerful live performances of new music to those who feel marginalized by their affliction.", "websiteLink": "http://transcendentpathways.org/", "name": "Transcendent Pathways", @@ -135,13 +112,11 @@ "logoUrl": "http://static1.squarespace.com/static/521b8957e4b024f66a58b214/t/521b8e9de4b093a8696eb9b8/1398718364447/?format=750w", "imageUrl": "https://trello-attachments.s3.amazonaws.com/54fdb0328917ca64e9e8a79f/54fdc3b710f67caf6da14719/x/49fbe0012179bf254928f3f2a44810b4/Screen_2BShot_2B2013-08-26_2Bat_2B1.32.35_2BPM.png", "estimatedHours": 200, - "currentStatus": "started" + "currentStatus": "started", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb8bdef", - "requestedDeliverables": [ - "other" - ], "whatDoesNonprofitDo": "We have provide volunteer matching fairs and silent art auctions at events across Canada. Rather than bid money on artwork, participants bid volunteer hours.", "websiteLink": "http://www.timeraiser.ca/", "name": "Timeraiser", @@ -152,19 +127,12 @@ "projectDescription": "Campers will build a mobile responsive web form to allow Timeraiser eventgoers to select which nonprofit organizations they're interested in volunteering with. System will have Salesforce integration and reporting capabilities.", "logoUrl": "http://www.timeraiser.ca/uploads/5/6/1/4/5614163/1277176.png?480", "imageUrl": "http://www.timeraiser.ca/uploads/5/6/1/4/5614163/______________4571248_orig.png", - "currentStatus": "started", - "interestedCampers": [], - "confirmedCampers": [], - "estimatedHours": 100, - "currentStatus": "completed" + "estimatedHours": 200, + "currentStatus": "completed", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb7bdef", - "requestedDeliverables": [ - "website", - "inventory", - "form" - ], "whatDoesNonprofitDo": "We focus on raising funds to assist injured homeless animals.", "websiteLink": "http://www.peoplesavinganimals.org/", "name": "People Saving Animals", @@ -178,15 +146,11 @@ "logoUrl": "https://scontent-sjc2-1.xx.fbcdn.net/hphotos-xfa1/v/t1.0-9/59709_501505959886494_1605714757_n.jpg?oh=e12c08c046d824765a02242b7c8c3bb5&oe=560CFA6A", "imageUrl": "https://scontent-sjc2-1.xx.fbcdn.net/hphotos-xta1/t31.0-8/11270516_844556088914811_757350153964826829_o.jpg", "estimatedHours": 300, - "currentStatus": "started" + "currentStatus": "started", + "moneySaved": 60000 }, { "id": "bd1325d8c464cbafaeb6bde2", - "requestedDeliverables": [ - "inventory", - "form", - "other" - ], "whatDoesNonprofitDo": "We preserve Florida's health by regulating septic contractors and reviewing logs of sewage collection and disposal.", "websiteLink": "http://www.floridahealth.gov/", "name": "Florida Department of Health", @@ -200,13 +164,11 @@ "logoUrl": "http://www.floridahealth.gov/_new/_files/images/DOH_logo.png", "imageUrl": "http://www.dep.state.fl.us/central/Home/Watershed/Home.jpg", "estimatedHours": 200, - "currentStatus": "started" + "currentStatus": "started", + "moneySaved": 40000 }, { "id": "bd1325d8c464cbafaeb6bde3", - "requestedDeliverables": [ - "website" - ], "whatDoesNonprofitDo": "We strengthen the value of songwriting and independent music in Columbus, Ohio.", "websiteLink": "http://columbussongwritersassociation.com", "name": "Columbus Songwriters Association", @@ -218,6 +180,87 @@ "logoUrl": "https://columbussongwritersassociation.files.wordpress.com/2014/06/csa-logo.jpeg?w=705&h=435&crop=1", "imageUrl": "https://columbussongwritersassociation.files.wordpress.com/2015/03/10502364_918551148225410_5082247612691070613_n.jpg?w=705&h=344&crop=1", "estimatedHours": 100, - "currentStatus": "completed" + "currentStatus": "completed", + "moneySaved": 20000 + }, + { + "id": "bd1325d8c464cbafaeb4bbb", + "whatDoesNonprofitDo": "We leverage all the benefits of cycling to support and improve the lives of youth and teens in the Triangle region.", + "websiteLink": "http://www.trianglebikeworks.org", + "name": "Triangle Bike Works", + "endUser": "Youth and teens in the Triangle region.", + "approvedDeliverables": [ + "website" + ], + "projectDescription": "Campers will build a website with donation integration.", + "logoUrl": "http://i.imgur.com/T5OkXuT.png", + "imageUrl": "http://i.imgur.com/7bOaMPq.jpg", + "estimatedHours": 100, + "currentStatus": "open", + "moneySaved": 0 + }, + { + "id": "bd1325d8c464cbafaeb4bccc", + "whatDoesNonprofitDo": "We work to eradicate female genital mutilation in the US and Gambia. We work with survivors and communities.", + "websiteLink": "http://safehandsforgirls.org/", + "name": "Safe Hands for Girls", + "endUser": "Supporters", + "approvedDeliverables": [ + "website" + ], + "projectDescription": "Campers will build a website with donation management.", + "logoUrl": "http://i.imgur.com/QnAY6Ji.png", + "imageUrl": "http://i.imgur.com/s9E4oa9.jpg", + "estimatedHours": 100, + "currentStatus": "open", + "moneySaved": 0 + }, + { + "id": "bd1325d8c464cbafaeb4beff", + "whatDoesNonprofitDo": "We're a part of the Department of Psychiatry at Mass General Hospital. We teach an innovative way for helping people that have challenging behaviors.", + "websiteLink": "http://www.thinkkids.org/", + "name": "Think Kids at Massachusetts General Hospital", + "endUser": "Volunteers, Administrators", + "approvedDeliverables": [ + "volunteer" + ], + "projectDescription": "We would like help developing a simple online based portal for both our trainees and trainers where we can store and share documents, track their progress, and incorporate a blackboard/chat forum.", + "logoUrl": "http://www.thinkkids.org/wp-content/themes/think-kids/images/logo.png", + "imageUrl": "http://i.imgur.com/hiGJms5.png", + "estimatedHours": 300, + "currentStatus": "open", + "moneySaved": 0 + }, + { + "id": "bd1325d8c464cbaeaeb4bdef", + "whatDoesNonprofitDo": "We enable, educate, and empower students from rural backgrounds in Uttar Pradesh, India.", + "websiteLink": "http://www.milaan.in/", + "name": "Milaan", + "endUser": "Supporters", + "approvedDeliverables": [ + "website" + ], + "projectDescription": "Campers will build a basic website for the US operations of Milaan. ", + "logoUrl": "http://i.imgur.com/GLq1qqD.png", + "imageUrl": "http://www.milaan.in/wp-content/uploads/2014/07/IMG_2624-e1432218749722.jpg", + "estimatedHours": 100, + "currentStatus": "open", + "moneySaved": 0 + }, + { + "id": "bd1325d8c464cbafaeb4beee", + "whatDoesNonprofitDo": "We're committed to closing the opportunity gap for children in Baltimore City by providing high quality after school and in-school programs.", + "websiteLink": "http://childfirstauthority.org/", + "name": "Child First Authority", + "endUser": "School Coordinators", + "approvedDeliverables": [ + "volunteer" + ], + "projectDescription": "Campers will build a dynamic database that will allow 7 community school coordinators to (1) input student-level absenteeism data, (2) code and track outreach efforts, (3) code root causes for absenteeism, and (4) track trends in each area. Currently, Child First uses an unwieldy excel spreadsheet to do this.", + "logoUrl": "http://i.imgur.com/YlPsQmN.jpg", + "imageUrl": "http://childfirstauthority.org/wp-content/uploads/2012/09/CFAHEADER7.gif", + "estimatedHours": 200, + "currentStatus": "open", + "moneySaved": 0 } ] diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 02cecc639e..c0ec900804 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -41,26 +41,19 @@ var R = require('ramda'), observableQueryFromModel = require('../utils/rx').observableQueryFromModel, userMigration = require('../utils/middleware').userMigration, - ifNoUserRedirectTo = require('../utils/middleware').ifNoUserRedirectTo; + ifNoUserRedirectTo = require('../utils/middleware').ifNoUserRedirectTo, + ifNoUserSend = require('../utils/middleware').ifNoUserSend; var challengeMapWithNames = utils.getChallengeMapWithNames(); var challengeMapWithIds = utils.getChallengeMapWithIds(); var challengeMapWithDashedNames = utils.getChallengeMapWithDashedNames(); +var challangesRegex = /^(bonfire|waypoint|zipline|basejump)/i; + +var dasherize = utils.dasherize; +var unDasherize = utils.unDasherize; var getMDNLinks = utils.getMDNLinks; -var challangesRegex = /^(bonfire|waypoint|zipline|basejump)/i; -function dasherize(name) { - return ('' + name) - .toLowerCase() - .replace(/\s/g, '-') - .replace(/[^a-z0-9\-\.]/gi, ''); -} - -function unDasherize(name) { - return ('' + name).replace(/\-/g, ' '); -} - function updateUserProgress(user, challengeId, completedChallenge) { var index = user.uncompletedChallenges.indexOf(challengeId); if (index > -1) { @@ -75,17 +68,32 @@ module.exports = function(app) { var router = app.loopback.Router(); var Challenge = app.models.Challenge; var User = app.models.User; + var redirectNonUser = + ifNoUserRedirectTo('/challenges/learn-how-free-code-camp-works'); + var send200toNonUser = ifNoUserSend(true); - router.post('/completed-challenge/', completedChallenge); - router.post('/completed-zipline-or-basejump', completedZiplineOrBasejump); - router.post('/completed-bonfire', completedBonfire); + router.post( + '/completed-challenge/', + send200toNonUser, + completedChallenge + ); + router.post( + '/completed-zipline-or-basejump', + send200toNonUser, + completedZiplineOrBasejump + ); + router.post( + '/completed-bonfire', + send200toNonUser, + completedBonfire + ); // the follow routes are covered by userMigration router.use(userMigration); router.get('/map', challengeMap); router.get( '/challenges/next-challenge', - ifNoUserRedirectTo('/challenges/learn-how-free-code-camp-works'), + redirectNonUser, returnNextChallenge ); @@ -93,7 +101,7 @@ module.exports = function(app) { router.get( '/challenges/', - ifNoUserRedirectTo('/challenges/learn-how-free-code-camp-works'), + redirectNonUser, returnCurrentChallenge ); @@ -308,7 +316,6 @@ module.exports = function(app) { .withLatestFrom( Rx.Observable.just(req.user), function(pairedWith, user) { - debug('yo'); return { user: user, pairedWith: pairedWith diff --git a/server/boot/fieldGuide.js b/server/boot/fieldGuide.js index ad142e8336..87fcdd0e69 100644 --- a/server/boot/fieldGuide.js +++ b/server/boot/fieldGuide.js @@ -1,11 +1,16 @@ -var R = require('ramda'), -// Rx = require('rx'), - debug = require('debug')('freecc:fieldguides'), - utils = require('../utils'); +var Rx = require('rx'); +var debug = require('debug')('freecc:fieldguides'); +var observeMethod = require('../utils/rx').observeMethod; +var saveUser = require('../utils/rx').saveUser; +var utils = require('../utils'); + +var allFieldGuideNamesAndIds = utils.allFieldGuideNamesAndIds(); module.exports = function(app) { var router = app.loopback.Router(); var FieldGuide = app.models.FieldGuide; + var findFieldGuideById = observeMethod(FieldGuide, 'findById'); + var findOneFieldGuide = observeMethod(FieldGuide, 'findOne'); router.get('/field-guide/all-articles', showAllFieldGuides); router.get('/field-guide/:fieldGuideName', returnIndividualFieldGuide); @@ -15,60 +20,66 @@ module.exports = function(app) { app.use(router); function returnIndividualFieldGuide(req, res, next) { - var dashedNameFromQuery = req.params.fieldGuideName; - if (req.user) { - var completed = req.user.completedFieldGuides; + var dashedName = req.params.fieldGuideName; + var userSave = Rx.Observable.just(req.user) + .filter(function(user) { + return !!user; + }) + .map(function(user) { + var completed = user.completedFieldGuides; - var uncompletedFieldGuides = utils.allFieldGuideIds() - .filter(function (elem) { - if (completed.indexOf(elem) === -1) { - return elem; - } - }); - req.user.uncompletedFieldGuides = uncompletedFieldGuides; - // TODO(berks): handle callback properly - req.user.save(function(err) { - if (err) { return next(err); } - }); - } - - FieldGuide.find({ where: {'dashedName': dashedNameFromQuery}}, - function(err, fieldGuideFromMongo) { - if (err) { - return next(err); - } - - if (fieldGuideFromMongo.length < 1) { - req.flash('errors', { - msg: '404: We couldn\'t find a field guide entry with that name. ' + - 'Please double check the name.' + var uncompletedFieldGuides = utils.allFieldGuideIds() + .filter(function(id) { + if (completed.indexOf(id) === -1) { + return id; + } }); + user.uncompletedFieldGuides = uncompletedFieldGuides; + return user; + }) + .flatMap(function(user) { + return saveUser(user); + }); - return res.redirect('/'); - } + var query = { where: { dashedName: { like: dashedName, options: 'i' } } }; - var fieldGuide = R.head(fieldGuideFromMongo); - fieldGuide.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, ''); + debug('find fieldGuide', query); + Rx.Observable.combineLatest( + // find that field guide + findOneFieldGuide(query), + userSave, + Rx.helpers.identity + ) + .subscribe( + // don't care about return from userSave + function(fieldGuide) { + if (!fieldGuide) { + req.flash('errors', { + msg: '404: We couldn\'t find a field guide entry with ' + + 'that name. Please double check the name.' + }); + return res.redirect('/field-guide/all-articles'); + } - // if (fieldGuide.dashedName !== dashedNameFromQuery) { - // return res.redirect('../field-guide/' + fieldGuide.dashedName); - // } - res.render('field-guide/show', { - title: fieldGuide.name, - fieldGuideId: fieldGuide.id, - description: fieldGuide.description.join('') - }); - } + if (fieldGuide.dashedName !== dashedName) { + return res.redirect('../field-guide/' + fieldGuide.dashedName); + } + res.render('field-guide/show', { + title: fieldGuide.name, + fieldGuideId: fieldGuide.id, + description: fieldGuide.description.join('') + }); + }, + next ); } function showAllFieldGuides(req, res) { - var allFieldGuideNamesAndIds = utils.allFieldGuideNamesAndIds(); - var completedFieldGuides = []; if (req.user && req.user.completedFieldGuides) { completedFieldGuides = req.user.completedFieldGuides; } + res.render('field-guide/all-articles', { allFieldGuideNamesAndIds: allFieldGuideNamesAndIds, completedFieldGuides: completedFieldGuides @@ -76,16 +87,19 @@ module.exports = function(app) { } function showCompletedFieldGuideFunction(req, res) { - req.flash('success', { - msg: [ - 'You\'ve read all our current Field Guide entries. ' + - 'If you have ideas for other Field Guide articles, ' + - 'please let us know on ', - 'GitHub.' - ].join('') - }); + req.flash( + 'success', + { + msg: [ + 'You\'ve read all our current Field Guide entries. ' + + 'If you have ideas for other Field Guide articles, ' + + 'please let us know on ', + 'GitHub.' + ].join('') + } + ); return res.redirect('../field-guide/how-do-i-use-this-guide'); } @@ -95,38 +109,40 @@ module.exports = function(app) { } if (!req.user.uncompletedFieldGuides.length) { - return showCompletedFieldGuideFunction(req, res, next); + return showCompletedFieldGuideFunction(req, res); } - FieldGuide.findById(req.user.uncompletedFieldGuides[0], - function(err, fieldGuide) { - - if (err) { return next(err); } + findFieldGuideById(req.user.uncompletedFieldGuides[0]).subscribe( + function(fieldGuide) { if (!fieldGuide) { - debug('bad juju in field guide %s', - req.user.uncompletedFieldGuides[0]); + debug( + 'field guide %s not found', + req.user.uncompletedFieldGuides[0] + ); return res.redirect('../field-guide/how-do-i-use-this-guide'); } return res.redirect('../field-guide/' + fieldGuide.dashedName); - }); + }, + next + ); + } + + function completedFieldGuide(req, res, next) { + var fieldGuideId = req.body.fieldGuideInfo.fieldGuideId; + + req.user.completedFieldGuides.push(fieldGuideId); + + var index = req.user.uncompletedFieldGuides.indexOf(fieldGuideId); + if (index > -1) { + req.user.progressTimestamps.push(Date.now()); + req.user.uncompletedFieldGuides.splice(index, 1); + } + + saveUser(req.user).subscribe( + function() { + res.send(true); + }, + next + ); } }; - -function completedFieldGuide(req, res, next) { - var fieldGuideId = req.body.fieldGuideInfo.fieldGuideId; - - req.user.completedFieldGuides.push(fieldGuideId); - - var index = req.user.uncompletedFieldGuides.indexOf(fieldGuideId); - if (index > -1) { - req.user.progressTimestamps.push(Date.now()); - req.user.uncompletedFieldGuides.splice(index, 1); - } - - req.user.save(function (err) { - if (err) { - return next(err); - } - res.send(true); - }); -} diff --git a/server/boot/nonprofits.js b/server/boot/nonprofits.js index 1d16e76b74..23bf2d979e 100644 --- a/server/boot/nonprofits.js +++ b/server/boot/nonprofits.js @@ -1,6 +1,13 @@ +var debug = require('debug')('freecc:nonprofits'); +var observeMethod = require('../utils/rx').observeMethod; +var unDasherize = require('../utils').unDasherize; +var dasherize = require('../utils').dasherize; + module.exports = function(app) { var router = app.loopback.Router(); var Nonprofit = app.models.Nonprofit; + var findNonprofits = observeMethod(Nonprofit, 'find'); + var findOneNonprofit = observeMethod(Nonprofit, 'findOne'); router.get('/nonprofits/directory', nonprofitsDirectory); router.get('/nonprofits/:nonprofitName', returnIndividualNonprofit); @@ -8,60 +15,71 @@ module.exports = function(app) { app.use(router); function nonprofitsDirectory(req, res, next) { - Nonprofit.find( - { where: { estimatedHours: { gt: 0 } } }, - function(err, nonprofits) { - if (err) { return next(err); } - + var sum = 0; + findNonprofits({}).subscribe( + function(nonprofits) { + nonprofits = nonprofits.sort(function(a, b) { + return b.moneySaved - a.moneySaved; + }); + totalSavings = function() { + for(i = 0; i < nonprofits.length; i++) { + sum += nonprofits[i].moneySaved; + } + return sum; + }(); res.render('nonprofits/directory', { title: 'Nonprofits we help', - nonprofits: nonprofits + nonprofits: nonprofits, + totalSavings: totalSavings.toString().replace(/000$/, ',000') }); - } + }, + next ); } function returnIndividualNonprofit(req, res, next) { var dashedName = req.params.nonprofitName; - var nonprofitName = dashedName.replace(/\-/g, ' '); + var nonprofitName = unDasherize(dashedName); + var query = { where: { name: { + like: nonprofitName, + options: 'i' + } } }; - Nonprofit.find( - { where: { name: new RegExp(nonprofitName, 'i') } }, - function(err, nonprofit) { - if (err) { - return next(err); - } - - if (nonprofit.length < 1) { + debug('looking for %s', nonprofitName); + debug('query', query); + findOneNonprofit(query).subscribe( + function(nonprofit) { + if (!nonprofit) { req.flash('errors', { msg: "404: We couldn't find a nonprofit with that name. " + 'Please double check the name.' }); - return res.redirect('/nonprofits'); } - nonprofit = nonprofit.pop(); - var dashedNameFull = nonprofit.name.toLowerCase().replace(/\s/g, '-'); + var dashedNameFull = dasherize(nonprofit.name); if (dashedNameFull !== dashedName) { return res.redirect('../nonprofit/' + dashedNameFull); } - var buttonActive = false; - if (req.user) { - if (req.user.uncompletedBonfires.length === 0) { - if (req.user.completedCoursewares.length > 63) { - var hasShownInterest = - nonprofit.interestedCampers.filter(function ( obj ) { - return obj.username === req.user.username; - }); - if (hasShownInterest.length === 0) { - buttonActive = true; - } - } + var buttonActive = false; + if ( + req.user && + req.user.uncompletedBonfires.length === 0 && + req.user.completedCoursewares.length > 63 + ) { + var hasShownInterest = + nonprofit.interestedCampers.filter(function(user) { + return user.username === req.user.username; + }); + + if (hasShownInterest.length === 0) { + buttonActive = true; } } + + res.render('nonprofits/show', { dashedName: dashedNameFull, title: nonprofit.name, @@ -95,35 +113,11 @@ module.exports = function(app) { interestedCampers: nonprofit.interestedCampers, assignedCampers: nonprofit.assignedCampers, buttonActive: buttonActive, + moneySaved: nonprofit.moneySaved, currentStatus: nonprofit.currentStatus }); - } + }, + next ); } - - /* - function interestedInNonprofit(req, res, next) { - if (req.user) { - Nonprofit.findOne( - { name: new RegExp(req.params.nonprofitName.replace(/-/, ' '), 'i') }, - function(err, nonprofit) { - if (err) { return next(err); } - nonprofit.interestedCampers.push({ - username: req.user.username, - picture: req.user.picture, - timeOfInterest: Date.now() - }); - nonprofit.save(function(err) { - if (err) { return next(err); } - req.flash('success', { - msg: 'Thanks for expressing interest in this nonprofit project! ' + - "We've added you to this project as an interested camper!" - }); - res.redirect('back'); - }); - } - ); - } - } - */ }; diff --git a/server/boot/randomAPIs.js b/server/boot/randomAPIs.js index 7b658a36df..e891c929bd 100644 --- a/server/boot/randomAPIs.js +++ b/server/boot/randomAPIs.js @@ -2,15 +2,12 @@ var Rx = require('rx'), Twit = require('twit'), async = require('async'), moment = require('moment'), - Slack = require('node-slack'), request = require('request'), debug = require('debug')('freecc:cntr:resources'), - constantStrings = require('../utils/constantStrings.json'), bootcampJson = require('../utils/bootcamps.json'), secrets = require('../../config/secrets'); -var slack = new Slack(secrets.slackHook); module.exports = function(app) { var router = app.loopback.Router(); var User = app.models.User; @@ -24,8 +21,6 @@ module.exports = function(app) { router.get('/api/trello', trelloCalls); router.get('/api/codepen/twitter/:screenName', twitter); router.get('/sitemap.xml', sitemap); - router.post('/get-help', getHelp); - router.post('/get-pair', getPair); router.get('/chat', chat); router.get('/coding-bootcamp-cost-calculator', bootcampCalculator); router.get('/coding-bootcamp-cost-calculator.json', bootcampCalculatorJson); @@ -34,77 +29,15 @@ module.exports = function(app) { router.get('/pmi-acp-agile-project-managers-form', agileProjectManagersForm); router.get('/nonprofits', nonprofits); router.get('/nonprofits-form', nonprofitsForm); + router.get('/our-sponsors', sponsors); router.get('/jobs-form', jobsForm); router.get('/submit-cat-photo', catPhotoSubmit); router.get('/unsubscribe/:email', unsubscribe); router.get('/unsubscribed', unsubscribed); router.get('/cats.json', getCats); - router.get('/api/slack', slackInvite); app.use(router); - function slackInvite(req, res, next) { - if (req.user) { - if (req.user.email) { - var invite = { - 'email': req.user.email, - 'token': process.env.SLACK_KEY, - 'set_active': true - }; - - var headers = { - 'User-Agent': 'Node Browser/0.0.1', - 'Content-Type': 'application/x-www-form-urlencoded' - }; - - var options = { - url: 'https://freecodecamp.slack.com/api/users.admin.invite', - method: 'POST', - headers: headers, - form: invite - }; - - request(options, function (error, response) { - if (!error && response.statusCode === 200) { - req.flash('success', { - msg: 'We\'ve successfully requested an invite for you.' + - ' Please check your email and follow the ' + - 'instructions from Slack.' - }); - req.user.sentSlackInvite = true; - req.user.save(function(err) { - if (err) { - return next(err); - } - return res.redirect('back'); - }); - } else { - req.flash('errors', { - msg: 'The invitation email did not go through for some reason.' + - ' Please try again or ' + - 'email us.' - }); - return res.redirect('back'); - } - }); - } else { - req.flash('notice', { - msg: 'Before we can send your Slack invite, we need your email ' + - 'address. Please update your profile information here.' - }); - return res.redirect('/account'); - } - } else { - req.flash('notice', { - msg: 'You need to sign in to Free Code Camp before ' + - 'we can send you a Slack invite.' - }); - return res.redirect('/account'); - } - } - function twitter(req, res, next) { // sends out random tweets about javascript var T = new Twit({ @@ -134,56 +67,6 @@ module.exports = function(app) { ); } - - function getHelp(req, res) { - var userName = req.user.username; - var code = req.body.payload.code ? '\n```\n' + - req.body.payload.code + '\n```\n' - : ''; - var challenge = req.body.payload.challenge; - - slack.send({ - text: '*@' + userName + '* wants help with ' + challenge + '. ' + - code + 'Hey, *@' + userName + '*, if no one helps you right ' + - 'away, try typing out your problem in detail to me. Like this: ' + - 'http://en.wikipedia.org/wiki/Rubber_duck_debugging', - channel: '#help', - username: 'Debuggy the Rubber Duck', - 'icon_url': 'https://pbs.twimg.com/profile_images/' + - '3609875545/569237541c920fa78d78902069615caf.jpeg' - }); - return res.sendStatus(200); - } - - function getPair(req, res) { - var userName = req.user.username; - var challenge = req.body.payload.challenge; - slack.send({ - text: [ - 'Anyone want to pair with *@', - userName, - '* on ', - challenge, - '?\nMake sure you install Screen Hero here: ', - 'http://freecodecamp.com/field-guide/how-do-i-install-screenhero\n', - 'Then start your pair program session with *@', - userName, - '* by typing \"/hero @', - userName, - '\" into Slack.\n And *@', - userName, - '*, be sure to launch Screen Hero, then keep coding. ', - 'Another camper may pair with you soon.' - ].join(''), - channel: '#letspair', - username: 'Companion Cube', - 'icon_url': - 'https://lh3.googleusercontent.com/-f6xDPDV2rPE/AAAAAAAAAAI/' + - 'AAAAAAAAAAA/mdlESXQu11Q/photo.jpg' - }); - return res.sendStatus(200); - } - function sitemap(req, res, next) { var appUrl = 'http://www.freecodecamp.com'; var now = moment(new Date()).format('YYYY-MM-DD'); @@ -337,6 +220,10 @@ module.exports = function(app) { res.send(bootcampJson); } + function chat(req, res) { + res.redirect('https://gitter.im/FreeCodeCamp/FreeCodeCamp'); + } + function jobsForm(req, res) { res.render('resources/jobs-form', { title: 'Employer Partnership Form for Job Postings,' + @@ -351,6 +238,12 @@ module.exports = function(app) { ); } + function sponsors(req, res) { + res.render('sponsors/sponsors', { + title: 'The Sponsors who make Free Code Camp Possible' + }); + } + function nonprofits(req, res) { res.render('resources/nonprofits', { title: 'A guide to our Nonprofit Projects' diff --git a/server/boot/story.js b/server/boot/story.js index 7603dfa20e..d693b7f48d 100755 --- a/server/boot/story.js +++ b/server/boot/story.js @@ -1,16 +1,84 @@ -var nodemailer = require('nodemailer'), +var Rx = require('rx'), + nodemailer = require('nodemailer'), + assign = require('object.assign'), sanitizeHtml = require('sanitize-html'), moment = require('moment'), mongodb = require('mongodb'), - // debug = require('debug')('freecc:cntr:story'), + debug = require('debug')('freecc:cntr:story'), utils = require('../utils'), + observeMethod = require('../utils/rx').observeMethod, + saveUser = require('../utils/rx').saveUser, + saveInstance = require('../utils/rx').saveInstance, MongoClient = mongodb.MongoClient, secrets = require('../../config/secrets'); +var foundationDate = 1413298800000; +var time48Hours = 172800000; + +var unDasherize = utils.unDasherize; +var dasherize = utils.dasherize; +var getURLTitle = utils.getURLTitle; + +var transporter = nodemailer.createTransport({ + service: 'Mandrill', + auth: { + user: secrets.mandrill.user, + pass: secrets.mandrill.password + } +}); + +function sendMailWhillyNilly(mailOptions) { + transporter.sendMail(mailOptions, function(err) { + if (err) { + console.log('err sending mail whilly nilly', err); + console.log('logging err but not carring'); + } + }); +} + +function hotRank(timeValue, rank) { + /* + * Hotness ranking algorithm: http://amix.dk/blog/post/19588 + * tMS = postedOnDate - foundationTime; + * Ranking... + * f(ts, 1, rank) = log(10)z + (ts)/45000; + */ + var z = Math.log(rank) / Math.log(10); + var hotness = z + (timeValue / time48Hours); + return hotness; +} + +function sortByRank(a, b) { + return hotRank(b.timePosted - foundationDate, b.rank) - + hotRank(a.timePosted - foundationDate, a.rank); +} + +function cleanData(data, opts) { + var options = assign( + {}, + { + allowedTags: [], + allowedAttributes: [] + }, + opts || {} + ); + return sanitizeHtml(data, options).replace(/";/g, '"'); +} + module.exports = function(app) { var router = app.loopback.Router(); var User = app.models.User; + var findUserById = observeMethod(User, 'findById'); + var findOneUser = observeMethod(User, 'findOne'); + var Story = app.models.Story; + var findStory = observeMethod(Story, 'find'); + var findOneStory = observeMethod(Story, 'findOne'); + var findStoryById = observeMethod(Story, 'findById'); + var countStories = observeMethod(Story, 'count'); + + var Comment = app.models.Comment; + var findCommentById = observeMethod(Comment, 'findById'); router.get('/stories/hotStories', hotJSON); router.get('/stories/comments/:id', comments); @@ -21,43 +89,32 @@ module.exports = function(app) { router.get('/stories/submit/new-story', preSubmit); router.post('/stories/preliminary', newStory); router.post('/stories/', storySubmission); - router.get('/stories/', hot); + router.get('/news/', hot); router.post('/stories/search', getStories); - router.get('/stories/:storyName', returnIndividualStory); + router.get('/news/:storyName', returnIndividualStory); router.post('/stories/upvote/', upvote); + router.get('/stories/:storyName', redirectToNews); app.use(router); - function hotRank(timeValue, rank) { - /* - * Hotness ranking algorithm: http://amix.dk/blog/post/19588 - * tMS = postedOnDate - foundationTime; - * Ranking... - * f(ts, 1, rank) = log(10)z + (ts)/45000; - */ - var time48Hours = 172800000; - var hotness; - var z = Math.log(rank) / Math.log(10); - hotness = z + (timeValue / time48Hours); - return hotness; + function redirectToNews(req, res) { + var url = req.originalUrl.replace(/^\/stories/, '/news'); + return res.redirect(url); } function hotJSON(req, res, next) { - Story.find({order: 'timePosted DESC', limit: 1000}, function(err, stories) { - if (err) { - return next(err); - } - var foundationDate = 1413298800000; - - var sliceVal = stories.length >= 100 ? 100 : stories.length; - return res.json(stories.map(function(elem) { - return elem; - }).sort(function(a, b) { - return hotRank(b.timePosted - foundationDate, b.rank, b.headline) - - hotRank(a.timePosted - foundationDate, a.rank, a.headline); - }).slice(0, sliceVal)); - - }); + var query = { + order: 'timePosted DESC', + limit: 1000 + }; + findStory(query).subscribe( + function(stories) { + var sliceVal = stories.length >= 100 ? 100 : stories.length; + var data = stories.sort(sortByRank).slice(0, sliceVal); + res.json(data); + }, + next + ); } function hot(req, res) { @@ -74,32 +131,11 @@ module.exports = function(app) { }); } - /* - * no used anywhere - function search(req, res) { - return res.render('stories/index', { - title: 'Search the archives of Camper News', - page: 'search' - }); - } - - function recent(req, res) { - return res.render('stories/index', { - title: 'Recently submitted stories on Camper News', - page: 'recent' - }); - } - */ - function preSubmit(req, res) { - var data = req.query; - var cleanData = sanitizeHtml(data.url, { - allowedTags: [], - allowedAttributes: [] - }).replace(/";/g, '"'); - if (data.url.replace(/&/g, '&') !== cleanData) { + var cleanedData = cleanData(data.url); + if (data.url.replace(/&/g, '&') !== cleanedData) { req.flash('errors', { msg: 'The data for this post is malformed' }); @@ -121,64 +157,54 @@ module.exports = function(app) { }); } - function returnIndividualStory(req, res, next) { var dashedName = req.params.storyName; + var storyName = unDasherize(dashedName); - var storyName = dashedName.replace(/\-/g, ' ').trim(); - - Story.find({where: {'storyLink': storyName}}, function(err, story) { - if (err) { - return next(err); - } - - - if (story.length < 1) { - req.flash('errors', { - msg: "404: We couldn't find a story with that name. " + - 'Please double check the name.' - }); - - return res.redirect('/stories/'); - } - - story = story.pop(); - var dashedNameFull = story.storyLink.toLowerCase() - .replace(/\s+/g, ' ') - .replace(/\s/g, '-'); - if (dashedNameFull !== dashedName) { - return res.redirect('../stories/' + dashedNameFull); - } - - var userVoted = false; - try { - var votedObj = story.upVotes.filter(function(a) { - return a['upVotedByUsername'] === req.user['profile']['username']; - }); - if (votedObj.length > 0) { - userVoted = true; + findOneStory({ where: { storyLink: storyName } }).subscribe( + function(story) { + if (!story) { + req.flash('errors', { + msg: "404: We couldn't find a story with that name. " + + 'Please double check the name.' + }); + return res.redirect('/news'); } - } catch(e) { - userVoted = false; - } - res.render('stories/index', { - title: story.headline, - link: story.link, - originalStoryLink: dashedName, - originalStoryAuthorEmail: story.author.email || '', - author: story.author, - description: story.description, - rank: story.upVotes.length, - upVotes: story.upVotes, - comments: story.comments, - id: story.id, - timeAgo: moment(story.timePosted).fromNow(), - image: story.image, - page: 'show', - storyMetaDescription: story.metaDescription, - hasUserVoted: userVoted - }); - }); + + var dashedNameFull = story.storyLink.toLowerCase() + .replace(/\s+/g, ' ') + .replace(/\s/g, '-'); + + if (dashedNameFull !== dashedName) { + return res.redirect('../stories/' + dashedNameFull); + } + + var username = req.user ? req.user.username : ''; + // true if any of votes are made by user + var userVoted = story.upVotes.some(function(upvote) { + return upvote.upVotedByUsername === username; + }); + + res.render('stories/index', { + title: story.headline, + link: story.link, + originalStoryLink: dashedName, + originalStoryAuthorEmail: story.author.email || '', + author: story.author, + description: story.description, + rank: story.upVotes.length, + upVotes: story.upVotes, + comments: story.comments, + id: story.id, + timeAgo: moment(story.timePosted).fromNow(), + image: story.image, + page: 'show', + storyMetaDescription: story.metaDescription, + hasUserVoted: userVoted + }); + }, + next + ); } function getStories(req, res, next) { @@ -224,57 +250,52 @@ module.exports = function(app) { } function upvote(req, res, next) { - var data = req.body.data; - Story.find({'id': data.id}, function(err, story) { - if (err) { - return next(err); - } - story = story.pop(); - story.rank++; - story.upVotes.push( - { + var id = req.body.data.id; + var story$ = findStoryById(id).shareReplay(); + + story$.flatMap(function(story) { + // find story author + return findUserById(story.author.userId); + }) + .flatMap(function(user) { + // if user deletes account then this will not exist + if (user) { + user.progressTimestamps.push(Date.now()); + } + return saveUser(user); + }) + .flatMap(function() { + req.user.progressTimestamps.push(Date.now()); + return saveUser(req.user); + }) + .flatMap(function() { + return story$; + }) + .flatMap(function(story) { + debug('upvoting'); + story.rank += 1; + story.upVotes.push({ upVotedBy: req.user.id, upVotedByUsername: req.user.username - } + }); + return saveInstance(story); + }) + .subscribe( + function(story) { + return res.send(story); + }, + next ); - story.markModified('rank'); - story.save(); - // NOTE(Berks): This logic is full of wholes and race conditions - // this could be the source of many 'can't set headers after - // they are sent' - // errors. This needs cleaning - User.findOne( - { where: { id: story.author.userId } }, - function(err, user) { - if (err) { return next(err); } - - user.progressTimestamps.push(Date.now() || 0); - user.save(function (err) { - req.user.save(function (err) { - if (err) { return next(err); } - }); - req.user.progressTimestamps.push(Date.now() || 0); - if (err) { - return next(err); - } - }); - } - ); - return res.send(story); - }); } function comments(req, res, next) { - var data = req.params.id; - Comment.find( - { where: {'id': data } }, - function(err, comment) { - if (err) { - return next(err); - } - comment = comment.pop(); - return res.send(comment); - }); + var id = req.params.id; + findCommentById(id).subscribe( + function(comment) { + res.send(comment); + }, + next + ); } function newStory(req, res, next) { @@ -282,10 +303,8 @@ module.exports = function(app) { return next(new Error('Must be logged in')); } var url = req.body.data.url; - var cleanURL = sanitizeHtml(url, { - allowedTags: [], - allowedAttributes: [] - }).replace(/"/g, '"'); + var cleanURL = cleanData(url); + if (cleanURL !== url) { req.flash('errors', { msg: "The URL you submitted doesn't appear valid" @@ -299,44 +318,46 @@ module.exports = function(app) { if (url.search(/^https?:\/\//g) === -1) { url = 'http://' + url; } - Story.find( - { where: {'link': url} }, - function(err, story) { - if (err) { - return next(err); - } - if (story.length) { - req.flash('errors', { - msg: "Someone's already posted that link. Here's the discussion." - }); - return res.json({ - alreadyPosted: true, - storyURL: '/stories/' + story.pop().storyLink - }); - } - utils.getURLTitle(url, processResponse); - } - ); - function processResponse(err, story) { - if (err) { - res.json({ + findStory({ where: { link: url } }) + .map(function(stories) { + if (stories.length) { + return { + alreadyPosted: true, + storyURL: '/stories/' + stories.pop().storyLink + }; + } + return { alreadyPosted: false, - storyURL: url, - storyTitle: '', - storyImage: '', - storyMetaDescription: '' - }); - } else { - res.json({ - alreadyPosted: false, - storyURL: url, - storyTitle: story.title, - storyImage: story.image, - storyMetaDescription: story.description - }); - } - } + storyURL: url + }; + }) + .flatMap(function(data) { + if (data.alreadyPosted) { + return Rx.Observable.just(data); + } + return Rx.Observable.fromNodeCallback(getURLTitle)(data.storyURL) + .map(function(story) { + return { + alreadyPosted: false, + storyURL: data.storyURL, + storyTitle: story.title, + storyImage: story.image, + storyMetaDescription: story.description + }; + }); + }) + .subscribe( + function(story) { + if (story.alreadyPosted) { + req.flash('errors', { + msg: "Someone's already posted that link. Here's the discussion." + }); + } + res.json(story); + }, + next + ); } function storySubmission(req, res, next) { @@ -356,63 +377,60 @@ module.exports = function(app) { link = 'http://' + link; } - Story.count({ - storyLink: { like: new RegExp('^' + storyLink + '(?: [0-9]+)?$', 'i') } - }, function (err, storyCount) { - if (err) { - return next(err); + var query = { + storyLink: { + like: ('^' + storyLink + '(?: [0-9]+)?$'), + options: 'i' } + }; - // if duplicate storyLink add unique number - storyLink = (storyCount === 0) ? storyLink : storyLink + ' ' + storyCount; + var savedStory = countStories(query) + .flatMap(function(storyCount) { + // if duplicate storyLink add unique number + storyLink = (storyCount === 0) ? + storyLink : + storyLink + ' ' + storyCount; - var link = data.link; - if (link.search(/^https?:\/\//g) === -1) { - link = 'http://' + link; - } - var story = new Story({ - headline: sanitizeHtml(data.headline, { - allowedTags: [], - allowedAttributes: [] - }).replace(/"/g, '"'), - timePosted: Date.now(), - link: link, - description: sanitizeHtml(data.description, { - allowedTags: [], - allowedAttributes: [] - }).replace(/"/g, '"'), - rank: 1, - upVotes: [({ - upVotedBy: req.user.id, - upVotedByUsername: req.user.username - })], - author: { - picture: req.user.picture, - userId: req.user.id, - username: req.user.username, - email: req.user.email - }, - comments: [], - image: data.image, - storyLink: storyLink, - metaDescription: data.storyMetaDescription, - originalStoryAuthorEmail: req.user.email - }); - story.save(function (err) { - if (err) { - return next(err); + var link = data.link; + if (link.search(/^https?:\/\//g) === -1) { + link = 'http://' + link; } - req.user.progressTimestamps.push(Date.now() || 0); - req.user.save(function (err) { - if (err) { - return next(err); - } - res.send(JSON.stringify({ - storyLink: story.storyLink.replace(/\s+/g, '-').toLowerCase() - })); + var newStory = new Story({ + headline: cleanData(data.headline), + timePosted: Date.now(), + link: link, + description: cleanData(data.description), + rank: 1, + upVotes: [({ + upVotedBy: req.user.id, + upVotedByUsername: req.user.username + })], + author: { + picture: req.user.picture, + userId: req.user.id, + username: req.user.username, + email: req.user.email + }, + comments: [], + image: data.image, + storyLink: storyLink, + metaDescription: data.storyMetaDescription, + originalStoryAuthorEmail: req.user.email }); + return saveInstance(newStory); }); - }); + + req.user.progressTimestamps.push(Date.now()); + return saveUser(req.user) + .flatMap(savedStory) + .subscribe( + function(story) { + res.json({ + storyLink: dasherize(story.storyLink) + }); + }, + next + ); } function commentSubmit(req, res, next) { @@ -420,11 +438,8 @@ module.exports = function(app) { if (!req.user) { return next(new Error('Not authorized')); } - var sanitizedBody = sanitizeHtml(data.body, - { - allowedTags: [], - allowedAttributes: [] - }).replace(/"/g, '"'); + var sanitizedBody = cleanData(data.body); + if (data.body !== sanitizedBody) { req.flash('errors', { msg: 'HTML is not allowed' @@ -449,7 +464,13 @@ module.exports = function(app) { commentOn: Date.now() }); - commentSave(comment, Story, res, next); + commentSave(comment, findStoryById).subscribe( + function() {}, + next, + function() { + res.send(true); + } + ); } function commentOnCommentSubmit(req, res, next) { @@ -458,13 +479,7 @@ module.exports = function(app) { return next(new Error('Not authorized')); } - var sanitizedBody = sanitizeHtml( - data.body, - { - allowedTags: [], - allowedAttributes: [] - } - ).replace(/"/g, '"'); + var sanitizedBody = cleanData(data.body); if (data.body !== sanitizedBody) { req.flash('errors', { @@ -490,119 +505,101 @@ module.exports = function(app) { topLevel: false, commentOn: Date.now() }); - commentSave(comment, Comment, res, next); + commentSave(comment, findCommentById).subscribe( + function() {}, + next, + function() { + res.send(true); + } + ); } function commentEdit(req, res, next) { - - Comment.find({ id: req.params.id }, function(err, cmt) { - if (err) { - return next(err); - } - cmt = cmt.pop(); - - if (!req.user && cmt.author.userId !== req.user.id) { - return next(new Error('Not authorized')); - } - - var sanitizedBody = sanitizeHtml(req.body.body, { - allowedTags: [], - allowedAttributes: [] - }).replace(/"/g, '"'); - if (req.body.body !== sanitizedBody) { - req.flash('errors', { - msg: 'HTML is not allowed' - }); - return res.send(true); - } - - cmt.body = sanitizedBody; - cmt.commentOn = Date.now(); - cmt.save(function(err) { - if (err) { - return next(err); + findCommentById(req.params.id) + .doOnNext(function(comment) { + if (!req.user && comment.author.userId !== req.user.id) { + throw new Error('Not authorized'); } - res.send(true); - }); - - }); - + }) + .flatMap(function(comment) { + var sanitizedBody = cleanData(req.body.body); + if (req.body.body !== sanitizedBody) { + req.flash('errors', { + msg: 'HTML is not allowed' + }); + } + comment.body = sanitizedBody; + comment.commentOn = Date.now(); + return saveInstance(comment); + }) + .subscribe( + function() { + res.send(true); + }, + next + ); } - function commentSave(comment, Context, res, next) { - comment.save(function(err, data) { - if (err) { - return next(err); - } - try { + function commentSave(comment, findContextById) { + return saveInstance(comment) + .flatMap(function(comment) { // Based on the context retrieve the parent // object of the comment (Story/Comment) - Context.find({ - id: data.associatedPost - }, function (err, associatedContext) { - if (err) { - return next(err); - } - associatedContext = associatedContext.pop(); - if (associatedContext) { - associatedContext.comments.push(data.id); - associatedContext.save(function (err) { - if (err) { - return next(err); - } - res.send(true); - }); - } - // Find the author of the parent object - User.findOne({ - 'profile.username': associatedContext.author.username - }, function(err, recipient) { - if (err) { - return next(err); - } - // If the emails of both authors differ, - // only then proceed with email notification - if ( - typeof data.author !== 'undefined' && - data.author.email && - typeof recipient !== 'undefined' && - recipient.email && - (data.author.email !== recipient.email) - ) { - var transporter = nodemailer.createTransport({ - service: 'Mandrill', - auth: { - user: secrets.mandrill.user, - pass: secrets.mandrill.password - } - }); + return findContextById(comment.associatedPost); + }) + .flatMap(function(associatedContext) { + if (associatedContext) { + associatedContext.comments.push(comment.id); + } + // NOTE(berks): saveInstance is safe + // it will automatically call onNext with null and onCompleted if + // argument is falsey or has no method save + return saveInstance(associatedContext); + }) + .flatMap(function(associatedContext) { + // Find the author of the parent object + // if no username + var username = associatedContext && associatedContext.author ? + associatedContext.author.username : + null; - var mailOptions = { - to: recipient.email, - from: 'Team@freecodecamp.com', - subject: data.author.username + - ' replied to your post on Camper News', - text: [ - 'Just a quick heads-up: ', - data.author.username + ' replied to you on Camper News.', - 'You can keep this conversation going.', - 'Just head back to the discussion here: ', - 'http://freecodecamp.com/stories/' + data.originalStoryLink, - '- the Free Code Camp Volunteer Team' - ].join('\n') - }; - - transporter.sendMail(mailOptions, function (err) { - if (err) { - return err; - } - }); - } + var query = { where: { username: username } }; + return findOneUser(query); + }) + // if no user is found we don't want to hit the doOnNext + // filter here will call onCompleted without running through the following + // steps + .filter(function(user) { + return !!user; + }) + // if this is called user is guarenteed to exits + // this is a side effect, hence we use do/tap observable methods + .doOnNext(function(user) { + // If the emails of both authors differ, + // only then proceed with email notification + if ( + comment.author && + comment.author.email && + user.email && + (comment.author.email !== user.email) + ) { + sendMailWhillyNilly({ + to: user.email, + from: 'Team@freecodecamp.com', + subject: comment.author.username + + ' replied to your post on Camper News', + text: [ + 'Just a quick heads-up: ', + comment.author.username, + ' replied to you on Camper News.', + 'You can keep this conversation going.', + 'Just head back to the discussion here: ', + 'http://freecodecamp.com/stories/', + comment.originalStoryLink, + '- the Free Code Camp Volunteer Team' + ].join('\n') }); - }); - } catch (e) { - return next(err); - } - }); + } + }); } }; diff --git a/server/server.js b/server/server.js index 4d59ccbe7f..b4d6fdf4ba 100755 --- a/server/server.js +++ b/server/server.js @@ -1,7 +1,6 @@ require('dotenv').load(); var pmx = require('pmx'); pmx.init(); -// handle uncaught exceptions. Forever will restart process on shutdown var R = require('ramda'), assign = require('lodash').assign, @@ -188,6 +187,8 @@ app.use( }) ); +// track when connecting to db starts +var startTime = Date.now(); boot(app, { appRootDir: __dirname, dev: process.env.NODE_ENV @@ -254,10 +255,7 @@ R.keys(passportProviders).map(function(strategy) { * 500 Error Handler. */ -// if (process.env.NODE_ENV === 'development') { -if (true) { // eslint-disable-line - // NOTE(berks): adding pmx here for Beta test. Remove for production - app.use(pmx.expressErrorHandler()); +if (process.env.NODE_ENV === 'development') { app.use(errorHandler({ log: true })); @@ -301,20 +299,46 @@ if (true) { // eslint-disable-line }); } -/** - * Start Express server. - */ +module.exports = app; - -app.listen(app.get('port'), function() { - console.log( - 'FreeCodeCamp server listening on port %d in %s mode', - app.get('port'), - app.get('env') - ); -}); +app.start = function () { + app.listen(app.get('port'), function() { + console.log( + 'FreeCodeCamp server listening on port %d in %s mode', + app.get('port'), + app.get('env') + ); + }); +}; // start the server if `$ node server.js` +if (require.main === module) { + if (process.env.NODE_ENV === 'production') { + var timeoutHandler; + console.log('waiting for db to connect'); + var onConnect = function() { + console.log('db connected in %s ms', Date.now() - startTime); + if (timeoutHandler) { + clearTimeout(timeoutHandler); + } + app.start(); + }; -module.exports = app; + var timeoutHandler = setTimeout(function() { + var message = + 'db did not after ' + + (Date.now() - startTime) + + ' ms connect crashing hard'; + + console.log(message); + // purposely shutdown server + // pm2 should restart this in production + throw new Error(message); + }, 5000); + + app.dataSources.db.on('connected', onConnect); + } else { + app.start(); + } +} diff --git a/server/utils/bootcamps.json b/server/utils/bootcamps.json index 3a1a7959bf..c9895932f6 100644 --- a/server/utils/bootcamps.json +++ b/server/utils/bootcamps.json @@ -1,23 +1,5 @@ -[{ - "name": "App Academy", - "cost": "18000", - "weeks": "12", - "finance": false, - "housing": "500", - "cities": [ - "new-york-city", - "san-francisco" - ] -}, { - "name": "Viking Code School", - "cost": "18000", - "weeks": "14", - "housing": "0", - "finance": false, - "cities": [ - "online" - ] -}, { +[ +{ "name": "Hack Reactor", "cost": "17780", "housing": "500", diff --git a/server/utils/index.js b/server/utils/index.js index bff016241c..ec64435a5f 100644 --- a/server/utils/index.js +++ b/server/utils/index.js @@ -20,11 +20,6 @@ var allFieldGuideIds, allFieldGuideNames, allNonprofitNames, challengeMapWithNames, allChallengeIds, challengeMapWithDashedNames; -/** - * GET / - * Resources. - */ - Array.zip = function(left, right, combinerFunction) { var counter, results = []; @@ -60,6 +55,17 @@ Array.zip = function(left, right, combinerFunction) { module.exports = { + dasherize: function dasherize(name) { + return ('' + name) + .toLowerCase() + .replace(/\s/g, '-') + .replace(/[^a-z0-9\-\.]/gi, ''); + }, + + unDasherize: function unDasherize(name) { + return ('' + name).replace(/\-/g, ' ').trim(); + }, + getChallengeMapForDisplay: function () { if (!challengeMapForDisplay) { challengeMapForDisplay = {}; @@ -188,35 +194,37 @@ module.exports = { return process.env.NODE_ENV; }, - getURLTitle: function (url, callback) { - (function () { - var result = {title: '', image: '', url: '', description: ''}; - request(url, function (error, response, body) { - if (!error && response.statusCode === 200) { - var $ = cheerio.load(body); - var metaDescription = $("meta[name='description']"); - var metaImage = $("meta[property='og:image']"); - var urlImage = metaImage.attr('content') ? - metaImage.attr('content') : - ''; + getURLTitle: function(url, callback) { + var result = { + title: '', + image: '', + url: '', + description: '' + }; + request(url, function(err, response, body) { + if (err || response.statusCode !== 200) { + return callback(new Error('failed')); + } + var $ = cheerio.load(body); + var metaDescription = $("meta[name='description']"); + var metaImage = $("meta[property='og:image']"); + var urlImage = metaImage.attr('content') ? + metaImage.attr('content') : + ''; - var metaTitle = $('title'); - var description = metaDescription.attr('content') ? - metaDescription.attr('content') : - ''; + var metaTitle = $('title'); + var description = metaDescription.attr('content') ? + metaDescription.attr('content') : + ''; - result.title = metaTitle.text().length < 90 ? - metaTitle.text() : - metaTitle.text().slice(0, 87) + '...'; + result.title = metaTitle.text().length < 90 ? + metaTitle.text() : + metaTitle.text().slice(0, 87) + '...'; - result.image = urlImage; - result.description = description; - callback(null, result); - } else { - callback(new Error('failed')); - } - }); - })(); + result.image = urlImage; + result.description = description; + callback(null, result); + }); }, getMDNLinks: function(links) { diff --git a/server/utils/middleware.js b/server/utils/middleware.js index 5af207e513..dc0219f0a4 100644 --- a/server/utils/middleware.js +++ b/server/utils/middleware.js @@ -43,3 +43,11 @@ exports.ifNoUserRedirectTo = function ifNoUserRedirectTo(url) { }; }; +exports.ifNoUserSend = function ifNoUserSend(sendThis) { + return function(req, res, next) { + if (req.user) { + return next(); + } + return res.status(200).send(sendThis); + }; +}; diff --git a/server/utils/rx.js b/server/utils/rx.js index 8a4003c00c..8088e163e0 100644 --- a/server/utils/rx.js +++ b/server/utils/rx.js @@ -1,25 +1,32 @@ var Rx = require('rx'); var debug = require('debug')('freecc:rxUtils'); -exports.saveUser = function saveUser(user) { +exports.saveInstance = function saveInstance(instance) { return new Rx.Observable.create(function(observer) { - if (!user || typeof user.save !== 'function') { - debug('no user or save method'); + if (!instance || typeof instance.save !== 'function') { + debug('no instance or save method'); observer.onNext(); return observer.onCompleted(); } - user.save(function(err, savedUser) { + instance.save(function(err, savedInstance) { if (err) { return observer.onError(err); } - debug('user saved'); - observer.onNext(savedUser); + debug('instance saved'); + observer.onNext(savedInstance); observer.onCompleted(); }); }); }; +// alias saveInstance +exports.saveUser = exports.saveInstance; + exports.observableQueryFromModel = function observableQueryFromModel(Model, method, query) { return Rx.Observable.fromNodeCallback(Model[method], Model)(query); }; + +exports.observeMethod = function observeMethod(Model, method) { + return Rx.Observable.fromNodeCallback(Model[method], Model); +}; diff --git a/server/views/challengeMap/show.jade b/server/views/challengeMap/show.jade index e80b209312..392e4275f7 100644 --- a/server/views/challengeMap/show.jade +++ b/server/views/challengeMap/show.jade @@ -98,21 +98,21 @@ block content li.large-p.negative-10 a(href="/challenges/#{challenge.dashedName}")= challenge.name - #announcementModal.modal(tabindex='-1') - .modal-dialog.animated.fadeInUp.fast-animation - .modal-content - .modal-header.challenge-list-header Add us to your LinkedIn profile - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body - h3.text-left LinkedIn now recognizes Free Code Camp as a university. - img.img-responsive.img-center(src='https://www.evernote.com/l/AHTzkHwtg-BHj57bqqDL7WFF8WgrI5V8cxwB/image.png') - h3.text-left It takes less than a minute to add Free Code Camp to your LinkedIn profile. - a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='/linkedin', target='_blank') Show me how to do this - a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up - script. - $(document).ready(function () { - if (!localStorage || !localStorage.linkedIn) { - $('#announcementModal').modal('show'); - localStorage.linkedIn = "true"; - } - }); + //#announcementModal.modal(tabindex='-1') + // .modal-dialog.animated.fadeInUp.fast-animation + // .modal-content + // .modal-header.challenge-list-header Add us to your LinkedIn profile + // a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + // .modal-body + // h3.text-left LinkedIn now recognizes Free Code Camp as a university. + // img.img-responsive.img-center(src='https://www.evernote.com/l/AHTzkHwtg-BHj57bqqDL7WFF8WgrI5V8cxwB/image.png') + // h3.text-left It takes less than a minute to add Free Code Camp to your LinkedIn profile. + // a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='/linkedin', target='_blank') Show me how to do this + // a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up + //script. + // $(document).ready(function () { + // if (!localStorage || !localStorage.linkedIn) { + // $('#announcementModal').modal('show'); + // localStorage.linkedIn = "true"; + // } + // }); diff --git a/server/views/coursewares/showBonfire.jade b/server/views/coursewares/showBonfire.jade index a52578dec0..cec1c955e7 100644 --- a/server/views/coursewares/showBonfire.jade +++ b/server/views/coursewares/showBonfire.jade @@ -84,25 +84,20 @@ block content label.negative-10.btn.btn-primary.btn-block#submitButton i.fa.fa-play | Run code (ctrl + enter) - #trigger-reset-modal.btn.btn-danger.btn-big.btn-block(data-toggle='modal', data-target='#reset-modal', data-backdrop='true') Reset Code - if (user && user.sentSlackInvite) - .button-spacer - .btn-group.input-group.btn-group-justified - label.btn.btn-success#trigger-help-modal - i.fa.fa-refresh - | Reset - label.btn.btn-success#trigger-help-modal - i.fa.fa-refresh - | Reset - label.btn.btn-success#trigger-help-modal - i.fa.fa-medkit - | Help - label.btn.btn-success#trigger-pair-modal - i.fa.fa-user-plus - | Pair - label.btn.btn-success#trigger-issue-modal - i.fa.fa-bug - | Bug + .button-spacer + .btn-group.input-group.btn-group-justified + label.btn.btn-success#trigger-reset-modal + i.fa.fa-refresh + | Reset + label.btn.btn-success#trigger-help-modal + i.fa.fa-medkit + | Help + label.btn.btn-success#trigger-pair-modal + i.fa.fa-user-plus + | Pair + label.btn.btn-success#trigger-issue-modal + i.fa.fa-bug + | Bug .button-spacer form.code .form-group.codeMirrorView diff --git a/server/views/coursewares/showHTML.jade b/server/views/coursewares/showHTML.jade index 2ebc64d0dd..ff93a7665d 100644 --- a/server/views/coursewares/showHTML.jade +++ b/server/views/coursewares/showHTML.jade @@ -33,20 +33,18 @@ block content label.btn.btn-primary.btn-block.negative-10#next-courseware-button .ion-checkmark-circled | Go to my next challenge (ctrl + enter) - - if (user.sentSlackInvite) - .button-spacer - .btn-group.input-group.btn-group-justified - label.btn.btn-success#trigger-help-modal - i.fa.fa-medkit - | Help - label.btn.btn-success#trigger-issue-modal - i.fa.fa-bug - | Bug - .button-spacer + .button-spacer + .btn-group.input-group.btn-group-justified + label.btn.btn-success#trigger-help-modal + i.fa.fa-medkit + | Help + label.btn.btn-success#trigger-issue-modal + i.fa.fa-bug + | Bug script. var userLoggedIn = true; else + .button-spacer a.btn.signup-btn.btn-block.btn-block.negative-15(href='/login') Sign in so you can save your progress script. var userLoggedIn = false; diff --git a/server/views/coursewares/showJS.jade b/server/views/coursewares/showJS.jade index 58737351ac..369e810061 100644 --- a/server/views/coursewares/showJS.jade +++ b/server/views/coursewares/showJS.jade @@ -35,18 +35,17 @@ block content span.ion-arrow-up-b | Less information #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) - if (user && user.sentSlackInvite) - .button-spacer - .btn-group.input-group.btn-group-justified - label.btn.btn-success#trigger-help-modal - i.fa.fa-medkit - | Help - label.btn.btn-success#trigger-pair-modal - i.fa.fa-user-plus - | Pair - label.btn.btn-success#trigger-issue-modal - i.fa.fa-bug - | Bug + .button-spacer + .btn-group.input-group.btn-group-justified + label.btn.btn-success#trigger-help-modal + i.fa.fa-medkit + | Help + label.btn.btn-success#trigger-pair-modal + i.fa.fa-user-plus + | Pair + label.btn.btn-success#trigger-issue-modal + i.fa.fa-bug + | Bug .spacer form.code .form-group.codeMirrorView diff --git a/server/views/coursewares/showVideo.jade b/server/views/coursewares/showVideo.jade index 4e9d82a6ec..ae3e049c90 100644 --- a/server/views/coursewares/showVideo.jade +++ b/server/views/coursewares/showVideo.jade @@ -21,14 +21,13 @@ block content script. var userLoggedIn = true; .button-spacer - if (user.sentSlackInvite) - .btn-group.input-group.btn-group-justified - .btn.btn-success.btn-big#trigger-help-editorless-modal - i.fa.fa-medkit - | Get help - .btn.btn-success.btn-big#trigger-issue-modal - i.fa.fa-bug - | Report a bug + .btn-group.input-group.btn-group-justified + .btn.btn-success.btn-big#trigger-help-modal-modal + i.fa.fa-medkit + | Get help + .btn.btn-success.btn-big#trigger-issue-modal + i.fa.fa-bug + | Report a bug .button-spacer else a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress diff --git a/server/views/coursewares/showZiplineOrBasejump.jade b/server/views/coursewares/showZiplineOrBasejump.jade index ae72c47528..6bd38d9737 100644 --- a/server/views/coursewares/showZiplineOrBasejump.jade +++ b/server/views/coursewares/showZiplineOrBasejump.jade @@ -18,18 +18,17 @@ block content br if (user) a.btn.btn-primary.btn-big.btn-block#completed-zipline-or-basejump I've completed this challenge (ctrl + enter) - if (user.sentSlackInvite) - .button-spacer - .btn-group.input-group.btn-group-justified - .btn.btn-success.btn-big#trigger-help-editorless-modal - i.fa.fa-medkit - | Help - .btn.btn-success.btn-big#trigger-pair-modal - i.fa.fa-user-plus - | Pair - .btn.btn-success.btn-big#trigger-issue-modal - i.fa.fa-bug - | Bug + .button-spacer + .btn-group.input-group.btn-group-justified + .btn.btn-success.btn-big#trigger-help-modal + i.fa.fa-medkit + | Help + .btn.btn-success.btn-big#trigger-pair-modal + i.fa.fa-user-plus + | Pair + .btn.btn-success.btn-big#trigger-issue-modal + i.fa.fa-bug + | Bug .button-spacer script. var userLoggedIn = true; diff --git a/server/views/field-guide/show.jade b/server/views/field-guide/show.jade index a81eb6682f..cb428e237e 100644 --- a/server/views/field-guide/show.jade +++ b/server/views/field-guide/show.jade @@ -12,10 +12,10 @@ block content .text-center if user && user.uncompletedFieldGuides.length > 0 .next-field-guide-button.btn.btn-primary.btn-big.btn-block Next article (ctrl + enter) - .ten-pixel-break + .button-spacer a.btn.btn-info.btn-big.btn-block(href='/field-guide/all-articles') Show me all articles if !user - .ten-pixel-break + .button-spacer a.btn.btn-big.signup-btn.btn-block(href='/login') Start learning to code (it's free) .spacer #fieldGuideId.hidden= fieldGuideId diff --git a/server/views/home.jade b/server/views/home.jade index f1058309b5..3740c64e3b 100644 --- a/server/views/home.jade +++ b/server/views/home.jade @@ -1,19 +1,6 @@ extends layout block content .jumbotron - if (user && user.progressTimestamps.length > 0) - .col-xs-12 - .embed-responsive.embed-responsive-16by9 - iframe.embed-responsive-item(src='//player.vimeo.com/video/129168884') - br - h3 Note: If you're using Firefox and the buttons aren't working, do a full refresh (control + f5 on Windows and command + shift + r on Mac). We're working on this. - h3 Note: If you've already completed the HTML, CSS, Bootstrap Waypoints, you do not need to do these new Waypoints. - h3 Note: If you were already doing full stack JavaScript Waypoints (Node.js, Angular.js), go ahead and start the Bonfires (Basic Algorithm Scripting). - h3 Thanks for your patience everyone! We're confident these curriculum improvements will better prepare you for your nonprofit projects and for the workplace. - br - br - br - br .text-center h1.hug-top Code with Us h2 Let's learn to code by building projects for nonprofits diff --git a/server/views/nonprofits/directory.jade b/server/views/nonprofits/directory.jade index 2cb2794cbc..e30a6671fd 100644 --- a/server/views/nonprofits/directory.jade +++ b/server/views/nonprofits/directory.jade @@ -7,6 +7,8 @@ block content .panel-heading.text-center Nonprofits We Help .panel-body .col-xs-12.col-sm-12.col-md-10.col-md-offset-1 + h1.text-primary.text-center Our campers have saved nonprofits $#{totalSavings}. + .spacer for nonprofit in nonprofits .spacer .row @@ -15,8 +17,10 @@ block content .col-xs-12.col-sm-9 h2.negative-15= nonprofit.name h3.negative-15= nonprofit.whatDoesNonprofitDo + if (nonprofit.moneySaved > 0) + h4.negative-15.text-primary Estimated Cost Savings for Nonprofit: $#{nonprofit.moneySaved.toString().replace(/000$/, ',000')} a.text-center.btn.btn-primary.btn-lg(href='/nonprofits/' + nonprofit.name.toLowerCase().replace(/\s/g, '-')) Read more - + .spacer .col-xs-12.col-sm-8.col-sm-offset-2 if (!user) a.btn.btn-cta.signup-btn.btn-block(href="/nonprofits-form") My nonprofit needs coding help diff --git a/server/views/nonprofits/show.jade b/server/views/nonprofits/show.jade index e8c5f8debc..f408a70aab 100644 --- a/server/views/nonprofits/show.jade +++ b/server/views/nonprofits/show.jade @@ -43,6 +43,9 @@ block content if (approvedOther) .ion-settings Other tools h3 Project Status: #{currentStatus} + if (moneySaved > 0) + h3.text-primary Estimated Cost Savings for Nonprofit: $#{moneySaved.toString().replace(/000$/, ',000')} + if (interestedCampers && interestedCampers.length > 0) h3 Interested campers: .col-xs-12.text-left diff --git a/server/views/partials/challenge-modals.jade b/server/views/partials/challenge-modals.jade index 5270e77cd4..ba8dc1becd 100644 --- a/server/views/partials/challenge-modals.jade +++ b/server/views/partials/challenge-modals.jade @@ -4,12 +4,12 @@ .modal-header.challenge-list-header Ready to pair program? a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body.text-center - h3 This will create a pair programming request. + h3 This will take you to our pair programming room where you can request a pair. h3 You'll need a(href='/field-guide/how-do-i-install-screenhero' target='_blank') Screen Hero | . h3 Other campers may then message you about pair programming. - a.btn.btn-lg.btn-primary.btn-block#i-want-to-pair(name='_csrf', value=_csrf) Create my pair request + a.btn.btn-lg.btn-primary.btn-block(href='https://gitter.im/FreeCodeCamp/LetsPair', data-dismiss='modal', aria-hidden='true' target='_blank') Take me to the pair programming room a.btn.btn-lg.btn-info.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel #issue-modal.modal(tabindex='-1') @@ -33,20 +33,6 @@ a(href='/field-guide/how-do-i-get-help-when-i-get-stuck' target='_blank') RSAP | . h3 If you've already read the errors and searched Google, you should ask for help. - h3 This will open a help request in our Help chat room. - a.btn.btn-lg.btn-primary.btn-block#i-want-help(name='_csrf', value=_csrf) Ask for help - a.btn.btn-lg.btn-info.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel - -#help-editorless-modal.modal(tabindex='-1') - .modal-dialog.animated.zoomIn.fast-animation - .modal-content - .modal-header.challenge-list-header Need some help? - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body.text-center - h3 Remember to use - a(href='/field-guide/how-do-i-get-help-when-i-get-stuck' target='_blank') RSAP - | . - h3 If you've already read the errors and searched Google, you should ask for help. - h3 This will open a help request in our Help chat room. - a.btn.btn-lg.btn-primary.btn-block#i-want-help-editorless(name='_csrf', value=_csrf) Ask for help + h3 This will take you to our help room. + a.btn.btn-lg.btn-primary.btn-block(href='https://gitter.im/FreeCodeCamp/LetsPair', data-dismiss='modal', aria-hidden='true' target='_blank') Take me to the help room a.btn.btn-lg.btn-info.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel diff --git a/server/views/partials/navbar.jade b/server/views/partials/navbar.jade index e35b9c5e8e..ee3b9fe135 100644 --- a/server/views/partials/navbar.jade +++ b/server/views/partials/navbar.jade @@ -16,7 +16,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height li a(href='//gitter.im/FreeCodeCamp/FreeCodeCamp', target='_blank') Chat li - a(href='/stories') News + a(href='/news') News li a(href='/field-guide') Guide li diff --git a/server/views/partials/universal-head.jade b/server/views/partials/universal-head.jade index 47bc657df6..c31b46da4c 100644 --- a/server/views/partials/universal-head.jade +++ b/server/views/partials/universal-head.jade @@ -32,7 +32,7 @@ script. window.moment || document.write('