Class: YearTermGenerator::Generator

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
jekyll/_plugins/yearterm-generator.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'jekyll/_plugins/yearterm-generator.rb', line 41

def generate(site)

    #initializes some variables that will be used inside blocks
    term_name = "termstring"
    term_year = 1
    term_month_code = 0

    # appt start and end dates for each term are stored in the site.data.univ.fsu-terms yaml file
    terms = site.data['univ']['fsu-terms']


    # run through the terms until we find the term that includes today's date
    # because there the term ends before the next term begins
    # (i.e. weekend in between is not in either term)
    # we just look for last term which starts before the current date.
    # This assumes that the terms are in chronological order in site.data.univ.fsu-terms

    term_set = true

    terms.each do |key, term|


        if term["appt_start_date"]


            if  Date.parse(term["appt_start_date"]) <= Date.today
                    term_name = term["name"]
                    term_year = Integer(term["year"])
            end
        end
    end

    # set the student central month code depending on the term
    spring_month_code = 1
    summer_month_code = 6
    fall_month_code = 9

    spring_term_name = "spring"
    summer_term_name = "summer"
    fall_term_name = "fall"


   if (term_name == spring_term_name)
        term_month_code = spring_month_code
    elsif (term_name == summer_term_name)
        term_month_code = summer_month_code
    elsif (term_name == fall_term_name)
        term_month_code = fall_month_code
    end


    # set the site.config variables
    site.config['current_year'] = term_year
    site.config['current_months'] = term_year * 12 + term_month_code
    site.config['current_term_name'] = term_name
    site.config['current_term_year'] = "#{"%s %d" % [term_name, term_year]}"
    site.config['current_term_key'] = "#{"%d_%s" % [term_year, term_name]}"
    site.config['current_term_code'] = "#{"%d/%d" % [term_year, term_month_code]}"


    # site.config['last_term_name'] = term_name
    # site.config['last_term_year'] = "#{"%s %d" % [term_name, term_year]}"
    # site.config['last_term_key'] = "#{"%d_%s" % [term_year, term_name]}"
    # site.config['last_term_code'] = "#{"%d/%d" % [term_year, term_month_code]}"
    
 
    # site.config['next_term_name'] = term_name
    # site.config['next_term_year'] = "#{"%s %d" % [term_name, term_year]}"
    # site.config['next_term_key'] = "#{"%d_%s" % [term_year, term_name]}"
    # site.config['next_term_code'] = "#{"%d/%d" % [term_year, term_month_code]}"       
    
    # site.config['next2_term_name'] = term_name
    # site.config['next2_term_year'] = "#{"%s %d" % [term_name, term_year]}"
    # site.config['next2_term_key'] = "#{"%d_%s" % [term_year, term_name]}"
    # site.config['next2_term_code'] = "#{"%d/%d" % [term_year, term_month_code]}"
    
    # site.config['next3_term_name'] = term_name
    # site.config['next3_term_year'] = "#{"%s %d" % [term_name, term_year]}"
    # site.config['next3_term_key'] = "#{"%d_%s" % [term_year, term_name]}"
    # site.config['next3_term_code'] = "#{"%d/%d" % [term_year, term_month_code]}"
    
    
    # set the academic year, which begins in fall term
    academic_year = term_year;
    if (term_name == "spring" || term_name == "summer")
        academic_year = term_year - 1
    end
    site.config['current_academic_year'] = academic_year
    site.config['current_academic_year_label'] = "#{"%d-%d" % [academic_year, academic_year +1]}"

    # set the previous academic year, which begins in fall term
    prior_academic_year = academic_year - 1;
    site.config['prior_academic_year'] = prior_academic_year
    site.config['prior_academic_year_label'] = "#{"%d-%d" % [prior_academic_year, prior_academic_year +1]}"

    # set the next academic year, which begins in fall term
    next_academic_year = academic_year + 1;
    site.config['next_academic_year'] = next_academic_year
    site.config['next_academic_year_label'] = "#{"%d-%d" % [next_academic_year, next_academic_year +1]}"


    # set fall, spring, summer keys for the 3 prior, current, and next academic years

    site.config['current_fall_year'] = "#{"%s %d" % [fall_term_name, academic_year]}"
    site.config['current_fall_key'] = "#{"%d_%s" % [academic_year, fall_term_name]}"
    site.config['current_fall_code'] = "#{"%d/%d" % [academic_year, fall_month_code]}"

    site.config['current_spring_year'] = "#{"%s %d" % [spring_term_name, academic_year+1]}"
    site.config['current_spring_key'] = "#{"%d_%s" % [academic_year+1, spring_term_name]}"
    site.config['current_spring_code'] = "#{"%d/%d" % [academic_year+1, spring_month_code]}"

		site.config['current_summer_year'] = "#{"%s %d" % [summer_term_name, academic_year+1]}"
    site.config['current_summer_key'] = "#{"%d_%s" % [academic_year+1, summer_term_name]}"
    site.config['current_summer_code'] = "#{"%d/%d" % [academic_year+1, summer_month_code]}"


		site.config['prior_fall_year'] = "#{"%s %d" % [fall_term_name, prior_academic_year]}"
		site.config['prior_fall_key'] = "#{"%d_%s" % [prior_academic_year, fall_term_name]}"
		site.config['prior_fall_code'] = "#{"%d/%d" % [prior_academic_year, fall_month_code]}"

		site.config['prior_spring_year'] = "#{"%s %d" % [spring_term_name, prior_academic_year+1]}"
		site.config['prior_spring_key'] = "#{"%d_%s" % [prior_academic_year+1, spring_term_name]}"
		site.config['prior_spring_code'] = "#{"%d/%d" % [prior_academic_year+1, spring_month_code]}"

		site.config['prior_summer_year'] = "#{"%s %d" % [summer_term_name, prior_academic_year+1]}"
		site.config['prior_summer_key'] = "#{"%d_%s" % [prior_academic_year+1, summer_term_name]}"
		site.config['prior_summer_code'] = "#{"%d/%d" % [prior_academic_year+1, summer_month_code]}"


		site.config['next_fall_year'] = "#{"%s %d" % [fall_term_name, next_academic_year]}"
		site.config['next_fall_key'] = "#{"%d_%s" % [next_academic_year, fall_term_name]}"
		site.config['next_fall_code'] = "#{"%d/%d" % [next_academic_year, fall_month_code]}"

		site.config['next_spring_year'] = "#{"%s %d" % [spring_term_name, next_academic_year+1]}"
		site.config['next_spring_key'] = "#{"%d_%s" % [next_academic_year+1, spring_term_name]}"
		site.config['next_spring_code'] = "#{"%d/%d" % [next_academic_year+1, spring_month_code]}"

		site.config['next_summer_year'] = "#{"%s %d" % [summer_term_name, next_academic_year+1]}"
		site.config['next_summer_key'] = "#{"%d_%s" % [next_academic_year+1, summer_term_name]}"
		site.config['next_summer_code'] = "#{"%d/%d" % [next_academic_year+1, summer_month_code]}"    


end