Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from askaway/embed-question
Embed question
- Loading branch information
Showing
18 changed files
with
94 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,6 @@ | |
height: 100px; | ||
} | ||
} | ||
.answers-count { | ||
margin-top: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
%form(ng-controller='AnswerFormCtrl' ng-submit="addAnswer()" name="new_answer" dirtyconfirm="new_answer") | ||
.form-group | ||
%textarea.form-control.required#answer-text(ng-model="question.answerText" placeholder='Write your answer...' ng-disabled="question.error_message" name="answer_body") | ||
%charcounter(for_model="question.answerText" maxlength="350") | ||
.alert.alert-warning(ng-show="question.error_message") | ||
{{question.error_message}} | ||
%a(href ng-show="question.error_message" ng-click="loadQuestion()") (Reload question) | ||
.answer-form-container(ng-show="question.can_answer") | ||
%div.media.comment.answer.answer-form | ||
%span.pull-left.hidden-xs | ||
%img.media-object.avatar.comment-avatar{src: current_user.try(:avatar_url) } | ||
.media-body | ||
%form(ng-controller='AnswerFormCtrl' ng-submit="addAnswer()" name="new_answer" dirtyconfirm="new_answer") | ||
.form-group | ||
%textarea.form-control.required#answer-text(ng-model="question.answerText" placeholder='Write your answer...' ng-disabled="question.error_message" name="answer_body") | ||
%charcounter(for_model="question.answerText" maxlength="350") | ||
.alert.alert-warning(ng-show="question.error_message") | ||
{{question.error_message}} | ||
%a(href ng-show="question.error_message" ng-click="loadQuestion()") (Reload question) | ||
|
||
%input.btn.btn-primary#post-answer(type="submit" ng-disabled="!question.answerText" ng-hide="question.error_message" data-disable-with="Post answer" value='Post answer') | ||
%input.btn.btn-primary#post-answer(type="submit" ng-disabled="!question.answerText" ng-hide="question.error_message" data-disable-with="Post answer" value='Post answer') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%script#question-data(type="application/json") | ||
=render(:template => "questions/show.json").html_safe | ||
.row(ng-controller='QuestionCtrl') | ||
.col-xs-12.col-question-list(ng-cloak='') | ||
.panel.panel-default | ||
.panel-body.question | ||
= render 'questions/show/heading' | ||
= render 'questions/show/answers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,15 @@ | ||
%script#question-data(type="application/json") | ||
=render(:template => "questions/show.json").html_safe | ||
.row(ng-controller='QuestionCtrl') | ||
.col-xs-12.col-md-8.col-md-offset-2(ng-cloak='') | ||
.col-question-list.col-xs-12.col-md-8.col-md-offset-2(ng-cloak='') | ||
.panel.panel-default | ||
.see-more-questions | ||
= link_to '← See more questions', root_path | ||
.panel-body.question | ||
.row | ||
.col-xs-2.col-sm-2 | ||
= render 'question_up_vote' | ||
.col-xs-10.col-sm-10 | ||
=render 'questions/question_body' | ||
.text-detail | ||
{{question.created_at}} ago | ||
by | ||
%span(ng-show="question.is_anonymous") {{question.user}} | ||
%a.emphasized(ng-hide="question.is_anonymous" ng-href="{{question.user_path}}") {{question.user}} | ||
.panel-body | ||
= render 'answers/answers_expanded' | ||
%li.list-group-item.comment-count | ||
%ng-pluralize(count="question.comments_count" when="{ '1': '1 COMMENT', 'other': '{} COMMENTS' }") | ||
.panel-body | ||
.row.comment-list | ||
.col-xs-12 | ||
- unless current_user.try(:can_answer?, @question) | ||
- if user_signed_in? | ||
= render 'comments/form' | ||
- else | ||
= link_to 'Log in', new_user_session_path | ||
to comment | ||
|
||
= render partial: 'comments/item' | ||
= render 'questions/show/heading' | ||
= render 'questions/show/answers' | ||
= render 'answers/form' | ||
= render 'questions/show/comments' | ||
|
||
- if current_user.try(:can_answer?, @question) | ||
= render 'answers/share' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.comment-count.answers-count | ||
%ng-pluralize(count="question.answers_count" when="{ '1': '1 ANSWER', 'other': '{} ANSWERS' }") | ||
= render 'answers/answers_expanded' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.comment-count | ||
%ng-pluralize(count="question.comments_count" when="{ '1': '1 COMMENT', 'other': '{} COMMENTS' }") | ||
.row.comment-list | ||
.col-xs-12 | ||
- unless current_user.try(:can_answer?, @question) | ||
- if user_signed_in? | ||
= render 'comments/form' | ||
- else | ||
= link_to 'Log in', new_user_session_path | ||
to comment | ||
|
||
= render partial: 'comments/item' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.row | ||
.col-xs-2.col-sm-2 | ||
= render 'questions/question_up_vote' | ||
.col-xs-10.col-sm-10 | ||
=render 'questions/question_list/question_body' | ||
.text-detail | ||
{{question.created_at}} ago | ||
by | ||
%span(ng-show="question.is_anonymous") {{question.user}} | ||
%a.emphasized(ng-hide="question.is_anonymous" ng-href="{{question.user_path}}") {{question.user}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Embed::QuestionsController, :type => :controller do | ||
# Just a simple test to make sure the embed controller/views are still working | ||
describe "GET #show" do | ||
render_views | ||
let(:question) { FactoryGirl.create(:question) } | ||
let(:response) { get :show, id: question.id } | ||
|
||
it "shows question" do | ||
expect(response).to be_success | ||
end | ||
end | ||
end |