Class: Locomotive::Api::ThemeAssetsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/api/theme_assets_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Locomotive::ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Class Method Details

.descriptionObject



32
33
34
35
36
37
38
39
40
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
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 32

def self.description
  {
    overall: %{Manage the assets (stylesheets, javascripts, images, fonts) used by a site},
    actions: {
      index: {
        description: %{Return all the theme assets},
        example: {
          command: %{curl 'http://mysite.com/locomotive/api/theme_assets.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      },
      show: {
        description: %{Return the attributes of a theme asset},
        response: Locomotive::ThemeAssetPresenter.getters_to_hash,
        example: {
          command: %{curl 'http://mysite.com/locomotive/api/theme_assets/4244af4ef0000002.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      },
      create: {
        description: %{Create a theme asset},
        params: Locomotive::ThemeAssetPresenter.setters_to_hash,
        example: {
          command: %{curl -d '...' 'http://mysite.com/locomotive/api/theme_assets.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      },
      update: {
        description: %{Update a theme asset},
        params: Locomotive::ThemeAssetPresenter.setters_to_hash,
        example: {
          command: %{curl -d '...' -X UPDATE 'http://mysite.com/locomotive/api/theme_assets/4244af4ef0000002.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      },
      destroy: {
        description: %{Delete a theme asset},
        example: {
          command: %{curl -X DELETE 'http://mysite.com/locomotive/api/theme_assets/4244af4ef0000002.json?auth_token=dtsjkqs1TJrWiSiJt2gg'},
          response: %(TODO)
        }
      }
    }
  }
end

Instance Method Details

#createObject



15
16
17
18
19
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 15

def create
  @theme_asset.from_presenter(params[:theme_asset])
  @theme_asset.save
  respond_with @theme_asset, location: main_app.locomotive_api_theme_assets_url
end

#destroyObject



27
28
29
30
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 27

def destroy
  @theme_asset.destroy
  respond_with @theme_asset
end

#indexObject



7
8
9
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 7

def index
  respond_with(@theme_assets.sort_by(&:local_path))
end

#showObject



11
12
13
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 11

def show
  respond_with @theme_asset
end

#updateObject



21
22
23
24
25
# File 'app/controllers/locomotive/api/theme_assets_controller.rb', line 21

def update
  @theme_asset.from_presenter(params[:theme_asset])
  @theme_asset.save
  respond_with @theme_asset, location: main_app.locomotive_api_theme_assets_url
end