Class: CssController

Inherits:
ApplicationController show all
Defined in:
app/controllers/css_controller.rb

Constant Summary

Constants included from PaginationHelper

PaginationHelper::DEFAULT_OPTIONS, PaginationHelper::OPTIONS

Instance Method Summary collapse

Methods included from PaginationHelper

included, #paginate, validate_options!

Instance Method Details

#editObject


16
17
18
19
# File 'app/controllers/css_controller.rb', line 16

def edit
  @lastpost   = current_user.last_post
  @stylesheet = current_user.stylesheet || current_user.build_stylesheet
end

#getstyleObject


4
5
6
7
8
9
# File 'app/controllers/css_controller.rb', line 4

def getstyle
  style = User.find(@params['id']).stylesheet.data rescue nil
  render_text('', 404) and return unless style
  response.headers['Content-type'] = 'text/css'
  render_text style
end

#indexObject


11
12
13
14
# File 'app/controllers/css_controller.rb', line 11

def index
  edit
  render_action 'edit'
end

#updateObject


21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/css_controller.rb', line 21

def update
  @stylesheet = current_user.stylesheet || current_user.build_stylesheet
  @stylesheet.data = @params['stylesheet']['data']
  if @stylesheet.save
    flash['notice'] = 'Stylesheet was successfully updated.'
    redirect_to_my_home
  else
    render_action 'edit'
  end
end