|
1 | 1 | module ApplicationHelper
|
2 | 2 | def quote_of_the_day
|
3 |
| - quotes = [ |
4 |
| - { text: "The only way to do great work is to love what you do.", author: "Steve Jobs" }, |
5 |
| - { text: "Life is what happens when you're busy making other plans.", author: "John Lennon" }, |
6 |
| - { text: "The future belongs to those who believe in the beauty of their dreams.", author: "Eleanor Roosevelt" }, |
7 |
| - { text: "Strive not to be a success, but rather to be of value.", author: "Albert Einstein" }, |
8 |
| - { text: "The best way to predict the future is to create it.", author: "Peter Drucker" }, |
9 |
| - { text: "The only impossible journey is the one you never begin.", author: "Tony Robbins" }, |
10 |
| - { text: "Believe you can and you're halfway there.", author: "Theodore Roosevelt" }, |
11 |
| - { text: "Do not wait to strike till the iron is hot, but make it hot by striking.", author: "William Butler Yeats" }, |
12 |
| - { text: "In three words I can sum up everything I've learned about life: it goes on.", author: "Robert Frost" }, |
13 |
| - { text: "You miss 100% of the shots you don't take.", author: "Wayne Gretzky" }, |
14 |
| - { text: "The best revenge is massive success.", author: "Frank Sinatra" }, |
15 |
| - { text: "Success usually comes to those who are too busy to be looking for it.", author: "Henry David Thoreau" }, |
16 |
| - { text: "Opportunities don't happen. You create them.", author: "Chris Grosser" }, |
17 |
| - { text: "Don't be pushed around by the fears in your mind. Be led by the dreams in your heart.", author: "Roy T. Bennett" }, |
18 |
| - { text: "You only live once, but if you do it right, once is enough.", author: "Mae West" }, |
19 |
| - { text: "The purpose of our lives is to be happy.", author: "Dalai Lama" }, |
20 |
| - { text: "Life is what happens when you're busy making other plans.", author: "John Lennon" }, |
21 |
| - { text: "The way to get started is to quit talking and begin doing.", author: "Walt Disney" }, |
22 |
| - { text: "You do not find the happy life. You make it.", author: "Camilla E. Kimball" }, |
23 |
| - { text: "Happiness is not something ready made. It comes from your own actions.", author: "Dalai Lama" }, |
24 |
| - { text: "It does not matter how slowly you go as long as you do not stop.", author: "Confucius" }, |
25 |
| - { text: "The only limit to our realization of tomorrow is our doubts of today.", author: "Franklin D. Roosevelt" }, |
26 |
| - { text: "Do what you can, with what you have, where you are.", author: "Theodore Roosevelt" }, |
27 |
| - { text: "You can never cross the ocean until you have the courage to lose sight of the shore.", author: "Christopher Columbus" }, |
28 |
| - { text: "The best time to plant a tree was 20 years ago. The second best time is now.", author: "Chinese Proverb" }, |
29 |
| - { text: "Act as if what you do makes a difference. It does.", author: "William James" }, |
30 |
| - { text: "Success is not in what you have, but who you are.", author: "Bo Bennett" }, |
31 |
| - { text: "Success is not final, failure is not fatal: It is the courage to continue that counts.", author: "Winston Churchill" }, |
32 |
| - { text: "The only person you are destined to become is the person you decide to be.", author: "Ralph Waldo Emerson" }, |
33 |
| - { text: "Don’t watch the clock; do what it does. Keep going.", author: "Sam Levenson" }, |
34 |
| - { text: "The only place where success comes before work is in the dictionary.", author: "Vidal Sassoon" }, |
35 |
| - { text: "Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle.", author: "Christian D. Larson" }, |
36 |
| - { text: "Don’t be afraid to give up the good to go for the great.", author: "John D. Rockefeller" }, |
37 |
| - { text: "You are never too old to set another goal or to dream a new dream.", author: "C.S. Lewis" }, |
38 |
| - { text: "The mind is everything. What you think you become.", author: "Buddha" }, |
39 |
| - { text: "Life is short, and it is up to you to make it sweet.", author: "Sarah Louise Delany" }, |
40 |
| - { text: "The best way to find yourself is to lose yourself in the service of others.", author: "Mahatma Gandhi" }, |
41 |
| - { text: "To live a creative life, we must lose our fear of being wrong.", author: "Joseph Chilton Pearce" }, |
42 |
| - { text: "In order to succeed, we must first believe that we can.", author: "Nikos Kazantzakis" }, |
43 |
| - { text: "You have within you right now, everything you need to deal with whatever the world can throw at you.", author: "Brian Tracy" }, |
44 |
| - { text: "The only way to achieve the impossible is to believe it is possible.", author: "Charles Kingsleigh" }, |
45 |
| - { text: "Start where you are. Use what you have. Do what you can.", author: "Arthur Ashe" }, |
46 |
| - { text: "You are not your resume, you are your work.", author: "Seth Godin" }, |
47 |
| - { text: "Do what you love, love what you do.", author: "Wayne W. Dyer" }, |
48 |
| - { text: "Success is walking from failure to failure with no loss of enthusiasm.", author: "Winston Churchill" }, |
49 |
| - { text: "The only way to make sense out of change is to plunge into it, move with it, and join the dance.", author: "Alan Watts" }, |
50 |
| - { text: "The best way out is always through.", author: "Robert Frost" }, |
51 |
| - { text: "It is never too late to be what you might have been.", author: "George Eliot" }, |
52 |
| - { text: "The only limit to our realization of tomorrow is our doubts of today.", author: "Franklin D. Roosevelt" }, |
53 |
| - { text: "The best revenge is massive success.", author: "Frank Sinatra" }, |
54 |
| - { text: "Don't watch the clock; do what it does. Keep going.", author: "Sam Levenson" }, |
55 |
| - { text: "Life is what happens when you're busy making other plans.", author: "John Lennon" }, |
56 |
| - { text: "The best way to predict the future is to create it.", author: "Peter Drucker" }, |
57 |
| - { text: "You miss 100% of the shots you don't take.", author: "Wayne Gretzky" }, |
58 |
| - { text: "Do what you can, with what you have, where you are.", author: "Theodore Roosevelt" }, |
59 |
| - { text: "Act as if what you do makes a difference. It does.", author: "William James" }, |
60 |
| - { text: "The only person you are destined to become is the person you decide to be.", author: "Ralph Waldo Emerson" }, |
61 |
| - { text: "The only way to do great work is to love what you do.", author: "Steve Jobs" }, |
62 |
| - { text: "You are never too old to set another goal or to dream a new dream.", author: "C.S. Lewis" }, |
63 |
| - { text: "Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle.", author: "Christian D. Larson" }, |
64 |
| - { text: "The future belongs to those who believe in the beauty of their dreams.", author: "Eleanor Roosevelt" }, |
65 |
| - { text: "Success is not in what you have, but who you are.", author: "Bo Bennett" }, |
66 |
| - { text: "Success usually comes to those who are too busy to be looking for it.", author: "Henry David Thoreau" }, |
67 |
| - { text: "You can never cross the ocean until you have the courage to lose sight of the shore.", author: "Christopher Columbus" }, |
68 |
| - { text: "The only limit to our realization of tomorrow is our doubts of today.", author: "Franklin D. Roosevelt" }, |
69 |
| - { text: "Opportunities don't happen. You create them.", author: "Chris Grosser" }, |
70 |
| - { text: "Do not wait to strike till the iron is hot, but make it hot by striking.", author: "William Butler Yeats" }, |
71 |
| - { text: "The only impossible journey is the one you never begin.", author: "Tony Robbins" }, |
72 |
| - { text: "You do not find the happy life. You make it.", author: "Camilla E. Kimball" }, |
73 |
| - { text: "Success is not final, failure is not fatal: It is the courage to continue that counts.", author: "Winston Churchill" }, |
74 |
| - { text: "The only way to achieve the impossible is to believe it is possible.", author: "Charles Kingsleigh" }, |
75 |
| - { text: "Start where you are. Use what you have. Do what you can.", author: "Arthur Ashe" }, |
76 |
| - { text: "You are not your resume, you are your work.", author: "Seth Godin" }, |
77 |
| - { text: "Do what you love, love what you do.", author: "Wayne W. Dyer" } |
78 |
| - ] |
| 3 | + quotes = YAML.load_file(Rails.root.join('config', 'quotes.yml')) |
| 4 | + locale = I18n.locale.to_s |
79 | 5 |
|
80 |
| - # Use the current date to select a quote, ensuring it changes daily |
81 |
| - quotes[Date.today.yday % quotes.length] |
| 6 | + return nil unless quotes[locale] && quotes[locale]['quotes'].any? |
| 7 | + |
| 8 | + date = Date.today.to_s |
| 9 | + quotes_for_locale = quotes[locale]['quotes'] |
| 10 | + |
| 11 | + # Use the date as a seed for the random number generator |
| 12 | + srand(date.hash) |
| 13 | + |
| 14 | + # Select a quote based on the seeded random number |
| 15 | + quotes_for_locale.sample |
82 | 16 | end
|
83 |
| - |
84 | 17 | end
|
0 commit comments