Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Markech
refinerycms-news
Commits
f91e8afa
Commit
f91e8afa
authored
Apr 17, 2012
by
James Thompson
Committed by
Uģis Ozols
May 31, 2012
Browse files
fix for archive issues
parent
5287eec8
Changes
3
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
f91e8afa
.DS_Store
Gemfile.lock
spec/dummy
.idea
\ No newline at end of file
app/helpers/refinery/news/items_helper.rb
View file @
f91e8afa
...
...
@@ -28,23 +28,16 @@ module Refinery
end
end
def
news_item_archive_link
(
item
)
if
item
.
publish_date
>=
Time
.
now
.
end_of_year
.
advance
(
:years
=>
-
3
)
post_date
=
item
.
publish_date
.
strftime
(
'%m/%Y'
)
year
=
post_date
.
split
(
'/'
)[
1
]
month
=
post_date
.
split
(
'/'
)[
0
]
count
=
News
::
Item
.
by_archive
(
Time
.
parse
(
post_date
)).
size
text
=
t
(
"date.month_names"
)[
month
.
to_i
]
+
"
#{
year
}
(
#{
count
}
)"
link_to
(
text
,
refinery
.
news_items_archive_path
(
:year
=>
year
,
:month
=>
month
))
else
post_date
=
post
.
publish_date
.
strftime
(
'01/%Y'
)
year
=
post_date
.
split
(
'/'
)[
1
]
count
=
Refinery
::
News
::
Item
.
by_year
(
Time
.
parse
(
post_date
)).
size
text
=
"
#{
year
}
(
#{
count
}
)"
link_to
(
text
,
refinery
.
news_items_archive_path
(
:year
=>
year
))
def
news_item_archive_links
html
=
''
@item_months
=
::
Refinery
::
News
::
Item
.
published
.
group_by
{
|
i
|
i
.
publish_date
.
beginning_of_month
}
@item_months
.
each
do
|
month
,
items
|
if
items
.
present?
text
=
"
#{
t
(
"date.month_names"
)[
month
.
month
]
}
#{
month
.
year
}
(
#{
items
.
count
}
)"
html
+=
"<li>
#{
link_to
(
text
,
refinery
.
news_items_archive_path
(
:year
=>
month
.
year
,
:month
=>
month
.
month
))
}
</li>"
end
end
content_tag
(
'ul'
,
raw
(
html
))
end
end
end
...
...
app/views/refinery/news/items/widgets/_news_archive.html.erb
View file @
f91e8afa
<section
id=
"news_archive_widget"
>
<h2>
<%=
t
(
'archives'
,
:scope
=>
'refinery.news.shared'
)
%>
</h2>
<nav>
<ul>
<%
items
.
each
do
|
item
|
%>
<li>
<%=
news_item_archive_link
(
item
)
%>
</li>
<%
end
%>
</ul>
<%=
news_item_archive_links
%>
</nav>
</section>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment