public function post_all() { $releases = Model_Release::query()->order_by('name')->get(); $smarty = Nathan_Controller::new_smarty(array('releases' => $releases, 'image_dim' => count($releases) < 3 ? '400x400' : '230x230')); $html = $smarty->fetch(APPPATH . 'views/releases/releases.smarty'); $this->response($html); }
public function post_tumblr() { $params = array('api_key' => Config::get('tumblr_key'), 'format' => 'raw'); $tumblr_addr = Config::get('tumblr_address'); $type = Input::post('type', ''); if ($tag = Input::post('tag')) { $params['tag'] = $tag; } $uri = "http://api.tumblr.com/v2/blog/{$tumblr_addr}/posts/{$type}?" . http_build_query($params); // Get data from tumblr API $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = json_decode(curl_exec($ch)); curl_close($ch); if (isset($data->meta) && $data->meta->status == 200 && $data->meta->msg == 'OK') { $smarty = Nathan_Controller::new_smarty(array('posts' => $data->response->posts)); $html = $smarty->fetch(APPPATH . 'views/blog/tumblr.smarty'); $this->response($html); } else { $this->response("<p>Error loading Tumblr data. Please try again later.</p>"); } }