Guest User

Untitled

a guest
Apr 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. def render_articles_by_date(articles)
  2.  
  3. s = ""
  4. year = ""
  5. month = ""
  6. year_started = false
  7. month_started = false
  8.  
  9. s = s + "<div id='archive'>"
  10.  
  11. for article in articles
  12. #
  13. if year != article.created_at.year.to_s then
  14. if year_started then
  15. if month_started then
  16. s = s + "</ul>"
  17. end
  18. s = s + "</li>"
  19. s = s + "</ul>"
  20. end
  21. year_started = true
  22. month_started = false
  23. year = article.created_at.year.to_s
  24. s = s + "<h2>" + year + "</h2>"
  25. s = s + "<ul>"
  26. s = s + "<li>"
  27. end
  28. #
  29. if month != article.created_at.month.to_s then
  30. if month_started then
  31. s = s + "</ul>"
  32. end
  33. month_started = true
  34. month = article.created_at.month.to_s
  35. s = s + "<h3>" + article.created_at.strftime("%B") + "</h3>"
  36. s = s + "<ul>"
  37. end
  38. #
  39. s = s + "<li>"
  40. #
  41. s = s + get_article_bullet(article.article_type)
  42. #
  43. s = s + article.created_at.day.to_s + "<sup>" + get_day_suffix(article.created_at.day) + "</sup> "
  44. if article.project.id > 1 then
  45. s = s + article.project.name + ": "
  46. end
  47. s = s + link_to_article(article)
  48. s = s + "</li>"
  49. end
  50. #
  51. if month_started then
  52. s = s + "</ul>"
  53. end
  54. if year_started then
  55. s = s + "</li>"
  56. s = s + "</ul>"
  57. end
  58. #
  59. s = s + "</div>"
  60. return s
  61. end
Add Comment
Please, Sign In to add comment