Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add featured question section to shadow question page #5861

Merged
merged 1 commit into from Jun 14, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to鈥
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -27,6 +27,27 @@ def index
.paginate(page: params[:page], per_page: 24)
end

def index_shadow
@title = 'Questions and Answers'
@questions = Node.questions
.where(status: 1)
.order('node.nid DESC')
.paginate(page: params[:page], per_page: 24)

@populartitle = 'Popular Questions'
@popularquestions = Node.questions
.where(status: 1)
@popularquestions = filter_questions_by_tag(@questions, params[:tagnames])
.order('views DESC')
.limit(20)

@popularwikis = Node.limit(10)
.where(type: 'page', status: 1)
.order('nid DESC')
@unpaginated = true

end

# a form for new questions, at /questions/new
def new
# use another node body as a template
@@ -0,0 +1,19 @@
<% unless node.is_a?(Comment) || node.is_a?(Revision) || node.type == 'page' %>

<div class="profile-image text-center">
<img class="rounded-circle img-fluid" id="profile-photo" src="<%= node.author.profile_image %>" />
</div>

<a class="author" href="/profile/<%= node.author.name %>">@<%= node.author.name %></a> <%= node.author.new_contributor %>
<% if node.has_power_tag('with') %>
with
<% node.coauthors.each_with_index do |coauthor,i| %>
<a href="/profile/<%= coauthor.username %>">
<%= coauthor.username%> <%= coauthor.new_contributor %></a>
<%= ',' if i < node.coauthors.length-1 %>
<% end %>
<% end %>
<% end %>

asked:
</span>
@@ -0,0 +1,84 @@
<% questions = questions || @popularquestions # accept local if present, default to instance %>
<div id="notes" class="col-md-12">
<div class="row">

<div class="col-md-2">
</div>

<% questions.limit(2).each_with_index do |node,i| %>
<div class="card <% if @widget %>col-xs-3 col-sm-3 col-md-3 <% end %>col-lg-3 note note-container-question" style="margin-top:20px;">
<div class="card-body">

<div class="card-info">
<p class="meta"><%= render partial: "dashboard/question_node_meta", locals: { node: node } %></p>
<h5><a class="question" <% if @widget %>target="_blank"<% end %> href="<%= node.path(:question) %>"><%= node.title %></a></h5>
<div>
<div class="answer">
<% if params[:controller] == 'questions' %>
<a class="peopleResponse" href="<%= node.path(:question) %>#answers" title="Answers"><%= node.answers.length %> people responded</a>
<% end %>
</div>
</div>
<a class="btn btn-outline-secondary" href="/q/<%= node.id %>" >Read More</a>
</div>

</div>
</div>

<% end %>

<div class="col-md-2">
</div>
</div>
</div>

<style>
.card {
This conversation was marked as resolved by CleverFool77

This comment has been minimized.

Copy link
@jywarren

jywarren Jun 13, 2019

Contributor

Should we start to consolidate these styles and re-use them across cards? What do you think?

This comment has been minimized.

Copy link
@CleverFool77

CleverFool77 Jun 14, 2019

Author Member

Though the cards looks same but still there are many differences. The positioning and size of cards in different pages varies.

This comment has been minimized.

Copy link
@jywarren

jywarren Jun 14, 2019

Contributor

OK, I still am thinking perhaps we should make a planning item for moving all the re-usable card layouts to one template folder so they're all next to one another. They are hard to find! Like /app/views/items or /app/views/cards maybe?

This comment has been minimized.

Copy link
@jywarren

jywarren Jun 14, 2019

Contributor

But doesn't have to be in this PR

This comment has been minimized.

Copy link
@CleverFool77

CleverFool77 Jun 14, 2019

Author Member

Sure. Should I do this in next PR ?

This comment has been minimized.

Copy link
@CleverFool77

CleverFool77 Jun 14, 2019

Author Member

Or Le'ts wait a bit for all the cards and then shift them altogether to /app/views/cards

background-color: #fff;
border: 1px solid;
border-color: #D3D3D3;
border-radius: 6px;
margin:2em 1.5em 2em 1.5em;
}
.card-body {
margin: auto;
text-align: center;
padding: 0.8em;
}
.profile-image {
margin-bottom: 1em;
}
.author {
color: #333;
font-weight: bold;
font-size: 1.2em;
}
.question {
font-style: italic;
color: #A9A9A9;
}
.peopleResponse {
color: #A9A9A9;
}
.answer {
margin-bottom: 1em;
}
.meta {
color: #999;
}
#profile-photo {
width: 6.5em;
border-color:#555;
border: 1px solid lightgrey;
}
</style>
@@ -1,4 +1,4 @@
<div class="row" style="padding:2em;">
<div class="row col-md-12" style="padding:2em;">
<div class="col-md-5">
<div class="profile-image text-center">
<img class="rounded-circle img-fluid" style= "width:40%;" id="profile-photo" src="https://avatars2.githubusercontent.com/u/4621650?s=200&v=4" />
@@ -12,28 +12,38 @@
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a href="https://publiclab.org/wiki/public-lab-q-and-a" style="text-decoration: underline;">Learn More >></a>
</div>
</div>
<div class="question-area">
<div class= "question-header">
<h5>What's your question?</h5>
<% if !current_user %>
<p>To ask a question, please <a href="/login?return_to=/questions">log in</a> or <a href="/signup?return_to=/questions">sign up</a> first.</p>
<% end %>
</div>
<div class= "question-form">
<form id="questions_searchform" role="search" autocomplete="off" action="/post">
<div class="input-group">
<textarea tabindex="1" id="questions_searchform_input" type="text" name="title" class="<%= "disabled " if !current_user %>form-control search-query typeahead" qryType="questions" placeholder="type your question"></textarea>
<input type="hidden" name="tags" value="question:general">
<input type="hidden" name="template" value="question">
<input type="hidden" name="redirect" value="question">
</div>
<div class="input-group-append">
<button id="question_search" type="submit" rel="tooltip" title="Ask a question with the entered title" class="btn btn-primary">Continue</button>
</div>
</form>
</div>
</div>
</div>
<div class="question-area col-md-12">
<div class= "question-header">
<h5>What's your question?</h5>
<% if !current_user %>
<p>To ask a question, please <a href="/login?return_to=/questions">log in</a> or <a href="/signup?return_to=/questions">sign up</a> first.</p>
<% end %>
</div>
<div class= "question-form">
<form id="questions_searchform" role="search" autocomplete="off" action="/post">
<div class="input-group">
<textarea tabindex="1" id="questions_searchform_input" type="text" name="title" class="<%= "disabled " if !current_user %>form-control search-query typeahead" qryType="questions" placeholder="type your question"></textarea>
<input type="hidden" name="tags" value="question:general">
<input type="hidden" name="template" value="question">
<input type="hidden" name="redirect" value="question">
</div>
<div class="input-group-append" style="padding-bottom:15px;">
<button id="question_search" type="submit" rel="tooltip" title="Ask a question with the entered title" class="btn btn-primary">Continue</button>
</div>
</form>
</div>
</div>

<div class="FeaturedQuestions col-md-12">

<span class="d-none d-lg-inline"><h2>Featured questions </h2></span>
<span><h6>see some of the great questions people have asked, and get a feel for how it works
</h6></span>
</div>

<%= render partial: "questions/questions_shadow" %>

<style>
.question-area{
margin:auto;
@@ -66,4 +76,9 @@
resize: none;
height: 170px;
}
.FeaturedQuestions {
text-align: center;
margin-top: 3em;
}
</style>
@@ -308,7 +308,8 @@
get 'questions' => 'questions#index'
get 'questions_shadow' => 'questions#index_shadow'
get 'question' => 'questions#index'
get 'questions/:author/:date/:id' => 'questions#show'
get 'question_shadow' => 'questions#index_shadow'
get 'questions/:author/:date/:id' => 'questions#show'
get 'questions/show/:id' => 'questions#show'
get 'q/:id' => 'questions#shortlink'
get 'questions/answered(/:tagnames)' => 'questions#answered'
@@ -50,6 +50,16 @@ class ScreenshotsTest < ApplicationSystemTestCase
take_screenshot
end

test 'questions' do
visit '/questions'
take_screenshot
end

test 'questions_shadow' do
visit '/questions_shadow'
take_screenshot
end

test 'wiki page with inline grids' do
node = nodes(:place) # /wiki/chicago page
revision = node.latest
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.