URL: /posts/archive/

Method: GET

Template: /posts/archive

Status codes:

* `200` ok
496951
function archive(req, res, next) {
  var years;

  db.posts.archive(function(err, posts) {
    if(err) { return next(err); }

    years = _.groupBy(posts, function(post) {
      return post.created_at.getFullYear();
    });

    res.format({
      'text/html': function() {
        res.render('posts/archive', {years: years});
      },
      'application/json': function() {
        res.json(years);
      }
    });
  });
}
1132030
def get_template(template_id, opts = {})
      data, _status_code, _headers = get_template_with_http_info(template_id, opts)
      data
    end
1061351
def update_url(self, url=None):
        
        if not url:
            raise ValueError("Neither a url or regex was provided to update_url.")
        post_url = "%s%s" % (self.BASE_URL, url)
        r = self.session.post(post_url)
        return int(r.status_code) < 500
1011793
def list_archives(self, offset=None, count=None, session_id=None):
        
        return self.get_archives(offset, count, session_id)
1300916
function ctc_get_archives() {

		global $wpdb;

		// Get post type
		$post_type = $this->ctc_instance['post_type'];

		// Get limit
		$limit = absint( $this->ctc_instance['limit'] );
		$sql_limit = '';
		if ( $limit > 0 ) {
			$sql_limit = $wpdb->prepare(
				"LIMIT %d",
				array(
					$limit
				)
			);
		}

		// Get archive months
		$archives = (array) $wpdb->get_results( $wpdb->prepare(
			"
				SELECT
					YEAR(post_date) AS `year`,
					MONTH(post_date) AS `month`,
					count(ID) as posts
				FROM $wpdb->posts
				WHERE
					post_type = %s
					AND post_status = 'publish'
				GROUP BY
					YEAR(post_date),
					MONTH(post_date)
				ORDER BY post_date DESC
				$sql_limit
			",
			array(
				$post_type
			)
		) );

		// Return filtered
		return apply_filters( 'ctc_archives_widget_get_archives', $archives );

	}
93483
def _get_archive_listing(self, archive_name):
        '''
        
        '''

        res = self.collection.find_one({'_id': archive_name})

        if res is None:
            raise KeyError

        return res
656008
function template(url, params) {
	var templated = url;
	var keys = _.keys(params);
	var loweredKeys = _.map(keys, function (key) {
		return key.toLowerCase();
	});
	var keyLookup = _.zipObject(loweredKeys, keys);

	_.each(templateParams(url), function replaceParam(param) {
		var normalisedParam = param.toLowerCase().substr(1);

		if (!keyLookup[normalisedParam]) {
			throw new Error('Missing ' + normalisedParam);
		}

		templated = templated.replace(param,
			params[keyLookup[normalisedParam]]);
		delete params[keyLookup[normalisedParam]];
	});

	return templated;
}
119823
def _get_responses(link):
    
    template = link.response_schema
    template.update({'description': 'Success'})
    res = {200: template}
    res.update(link.error_status_codes)
    return res
769474
def archive(self):
        
        ids = self.rpc_model.search(self.domain, context=self.context)
        if ids:
            self.rpc_model.write(ids, {'active': False})
413650
def run_check200(_):
    '''
    
    '''

    tstr = ''
    idx = 1
    for kind in config.router_post.keys():
        posts = MPost.query_all(kind=kind, limit=20000)
        for post in posts:
            the_url0 = '{site_url}/{kind_url}/{uid}'.format(
                site_url=config.SITE_CFG['site_url'],
                kind_url=config.router_post[post.kind],
                uid=post.uid)

            the_url = '{site_url}/{kind_url}/_edit/{uid}'.format(
                site_url=config.SITE_CFG['site_url'],
                kind_url=config.router_post[post.kind],
                uid=post.uid)
            req = requests.get(the_url0)

            if req.status_code == 200:
                pass
            else:
                print(the_url0)
                tstr = tstr + DT_STR.format(idx=str(idx).zfill(2), url0=the_url0, code=req.status_code, edit_link=the_url)
                idx = idx + 1

    time_local = time.localtime(timestamp())
    with open('xx200_{d}.html'.format(d=str(time.strftime("%Y_%m_%d", time_local))), 'w') as fileo:
        fileo.write(HTML_TMPL.format(cnt=tstr))
    print('Checking 200 finished.')
348795
def get_template_names(self):
        
        year = self.get_archive_part_value('year')
        week = self.get_archive_part_value('week')
        month = self.get_archive_part_value('month')
        day = self.get_archive_part_value('day')

        templates = []
        path = 'zinnia/archives'
        template_names = self.get_default_base_template_names()
        for template_name in template_names:
            templates.extend([template_name,
                              'zinnia/%s' % template_name,
                              '%s/%s' % (path, template_name)])
        if year:
            for template_name in template_names:
                templates.append(
                    '%s/%s/%s' % (path, year, template_name))
        if week:
            for template_name in template_names:
                templates.extend([
                    '%s/week/%s/%s' % (path, week, template_name),
                    '%s/%s/week/%s/%s' % (path, year, week, template_name)])
        if month:
            for template_name in template_names:
                templates.extend([
                    '%s/month/%s/%s' % (path, month, template_name),
                    '%s/%s/month/%s/%s' % (path, year, month, template_name)])
        if day:
            for template_name in template_names:
                templates.extend([
                    '%s/day/%s/%s' % (path, day, template_name),
                    '%s/%s/day/%s/%s' % (path, year, day, template_name),
                    '%s/month/%s/day/%s/%s' % (path, month, day,
                                               template_name),
                    '%s/%s/%s/%s/%s' % (path, year, month, day,
                                        template_name)])

        if self.template_name is not None:
            templates.append(self.template_name)

        templates.reverse()
        return templates
637015
def posts_template_data(post_items)
      if post_items.nil?
        return []
      end

      template_data = post_items.map do |post|
        {
          :title    => post.data['title'],
          :filename => post.name,
          :date     => post.date
        }
      end

      template_data.sort! { |x,y| y[:date] <=> x[:date] }

      template_data
    end
230791
def get_type_by_url

      return 'P' if params[:slug].blank?

      # split the url up into segments
      segments = params[:slug].split('/')

      # general variables
      url = params[:slug]
      article_url = Setting.get('articles_slug')
      category_url = Setting.get('category_slug')
      tag_url = Setting.get('tag_slug')

      status = "(post_status = 'Published' AND post_date <= CURRENT_TIMESTAMP AND disabled = 'N')"

      # HACK: this needs to be optimised
      
      # is it a article post or a page post
      if segments[0] == article_url
        if !segments[1].blank?
          if segments[1] == category_url || segments[1] == tag_url
            # render a category or tag page
            return 'CT'
          elsif segments[1].match(/\A\+?\d+(?:\.\d+)?\Z/)
            # render the archive page
            return 'AR'
          else
            # otherwise render a single article page
            return 'A'
          end
        else
          # render the overall all the articles
          return 'C'
        end

      else
        # render a page
        return 'P'
      end

    end
415099
def render_archive(entries):
    """"""
    context = GLOBAL_TEMPLATE_CONTEXT.copy()
    context['entries'] = entries
    _render(context, 'archive_index.html',
            os.path.join(CONFIG['output_to'], 'archive/index.html')),
38713
private void parseTemplate() {
    /*
     * query string and path literals have different reserved characters and different encoding
     * requirements. to ensure compliance with RFC 6570, we'll need to encode query literals
     * differently from path literals. let's look at the template to see if it contains a query
     * string and if so, keep track of where it starts.
     */
    Matcher queryStringMatcher = QUERY_STRING_PATTERN.matcher(this.template);
    if (queryStringMatcher.find()) {
      /*
       * the template contains a query string, split the template into two parts, the path and query
       */
      String path = this.template.substring(0, queryStringMatcher.start());
      String query = this.template.substring(queryStringMatcher.end() - 1);
      this.parseFragment(path, false);
      this.parseFragment(query, true);
    } else {
      /* parse the entire template */
      this.parseFragment(this.template, false);
    }
  }
1338099
def obtain_the_permalink(check = nil, render_inline = true)
      site_url = Setting.get('site_url')
      post = obtain_record(check)

      return '' if post.blank?

      article_url = Setting.get('articles_slug')

      url =
        if post.post_type == 'post'
           site_url("#{article_url}#{post.structured_url}")
        else
          site_url("#{post.structured_url}")
        end

      if render_inline
        render :inline => url
      else
        url
      end

    end
929901
def route_dynamic_page(params)

      # split the url up into segments
      segments = params[:slug].split('/')

      # general variables
      url = params[:slug]
      article_url = Setting.get('articles_slug')
      category_url = Setting.get('category_slug')
      tag_url = Setting.get('tag_slug')

      status = "(post_status = 'Published' AND post_date <= CURRENT_TIMESTAMP AND disabled = 'N')"
      # is it a article post or a page post
      case get_type_by_url
      when "CT"
        render_category segments, article_url, true, status
      when "AR"
        render_archive segments, article_url
      when "A"
        render_single segments, article_url, status
      when "C"
        render_category segments, article_url, false, status
      when "P"
        render_page url, status
      end

    end