summaryrefslogtreecommitdiffstats
path: root/mm/slab.c
AgeCommit message (Expand)Author
2018-04-13mm, slab: reschedule cache_reap() on the same CPUVlastimil Babka
2018-04-05slab, slub: skip unnecessary kasan_cache_shutdown()Shakeel Butt
2018-04-05kasan: make kasan_cache_create() work with 32-bit slab cache sizesAlexey Dobriyan
2018-04-05slab: make kmem_cache_flags accept 32-bit object sizeAlexey Dobriyan
2018-04-05slab: make kmem_cache_create() work with 32-bit sizesAlexey Dobriyan
2018-03-28mm, slab: memcg_link the SLAB's kmem_cacheShakeel Butt
2018-02-06kasan: don't use __builtin_return_address(1)Dmitry Vyukov
2018-02-03Merge tag 'usercopy-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/g...Linus Torvalds
2018-01-31mm/slab.c: remove redundant assignments for slab_stateOscar Salvador
2018-01-15usercopy: Mark kmalloc caches as usercopy cachesDavid Windsor
2018-01-15usercopy: Allow strict enforcement of whitelistsKees Cook
2018-01-15usercopy: WARN() on slab cache usercopy region violationsKees Cook
2018-01-15usercopy: Prepare for usercopy whitelistingDavid Windsor
2018-01-15usercopy: Include offset in hardened usercopy reportKees Cook
2017-12-14mm/slab.c: do not hash pointers when debugging slabGeert Uytterhoeven
2017-11-15kmemcheck: stop using GFP_NOTRACK and SLAB_NOTRACKLevin, Alexander (Sasha Levin)
2017-11-15kmemcheck: remove annotationsLevin, Alexander (Sasha Levin)
2017-11-15slab, slub, slob: convert slab_flags_t to 32-bitAlexey Dobriyan
2017-11-15slab, slub, slob: add slab_flags_tAlexey Dobriyan
2017-11-15mm/slab.c: only set __GFP_RECLAIMABLE onceDavid Rientjes
2017-11-15mm: slabinfo: remove CONFIG_SLABINFOYang Shi
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman
2017-07-06mm: memcontrol: account slab stats per lruvecJohannes Weiner
2017-07-06mm: vmstat: move slab statistics from zone to node countersJohannes Weiner
2017-07-06mm/slab.c: replace open-coded round-up code with ALIGNCanjiang Lu
2017-05-10Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kerne...Linus Torvalds
2017-05-03slab: avoid IPIs when creating kmem cachesGreg Thelen
2017-04-18mm: Rename SLAB_DESTROY_BY_RCU to SLAB_TYPESAFE_BY_RCUPaul E. McKenney
2017-03-02sched/headers: Prepare to move kstack_end() from <linux/sched.h> to <linux/sc...Ingo Molnar
2017-02-22slab: introduce __kmemcg_cache_deactivate()Tejun Heo
2017-02-22Revert "slub: move synchronize_sched out of slab_mutex on shrink"Tejun Heo
2017-02-22mm, slab: rename kmalloc-node cache to kmalloc-<size>Vlastimil Babka
2017-01-10mm/slab.c: fix SLAB freelist randomization duplicate entriesJohn Sperbeck
2016-12-13Merge branch 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wqLinus Torvalds
2016-12-12mm, slab: maintain total slab count instead of active countDavid Rientjes
2016-12-12mm, slab: faster active and free statsGreg Thelen
2016-12-12slub: move synchronize_sched out of slab_mutex on shrinkVladimir Davydov
2016-10-27mm/slab: improve performance of gathering slabinfo statsAruna Ramakrishna
2016-10-27mm/slab: fix kmemcg cache creation delayed issueJoonsoo Kim
2016-10-19Merge branch 'for-4.9' into for-4.10Tejun Heo
2016-09-17slab, workqueue: remove keventd_up() usageTejun Heo
2016-09-06slab: Convert to hotplug state machineSebastian Andrzej Siewior
2016-08-08Merge tag 'usercopy-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/ke...Linus Torvalds
2016-08-02treewide: replace obsolete _refok by __refFabian Frederick
2016-08-02mm/kasan: get rid of ->state in struct kasan_alloc_metaAndrey Ryabinin
2016-07-26mm/slab: use list_move instead of list_del/list_addWei Yongjun
2016-07-26slab: do not panic on invalid gfp_maskMichal Hocko
2016-07-26slab: make GFP_SLAB_BUG_MASK information more human readableMichal Hocko
2016-07-26mm: reorganize SLAB freelist randomizationThomas Garnier
2016-07-26mm: SLAB hardened usercopy supportKees Cook
6' href='#n96'>96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
// Copyright 2017-present The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package output

import (
	"fmt"
	"strings"

	"github.com/spf13/hugo/media"
)

var (
	// An ordered list of built-in output formats
	// See https://www.ampproject.org/learn/overview/
	AMPType = Type{
		Name:      "AMP",
		MediaType: media.HTMLType,
		BaseName:  "index",
	}

	CSSType = Type{
		Name:      "CSS",
		MediaType: media.CSSType,
		BaseName:  "styles",
	}

	HTMLType = Type{
		Name:      "HTML",
		MediaType: media.HTMLType,
		BaseName:  "index",
	}

	JSONType = Type{
		Name:        "JSON",
		MediaType:   media.HTMLType,
		BaseName:    "index",
		IsPlainText: true,
	}

	RSSType = Type{
		Name:      "RSS",
		MediaType: media.RSSType,
		BaseName:  "index",
	}
)

var builtInTypes = map[string]Type{
	strings.ToLower(AMPType.Name):  AMPType,
	strings.ToLower(CSSType.Name):  CSSType,
	strings.ToLower(HTMLType.Name): HTMLType,
	strings.ToLower(JSONType.Name): JSONType,
	strings.ToLower(RSSType.Name):  RSSType,
}

type Types []Type

// Type represents an output represenation, usually to a file on disk.
type Type struct {
	// The Name is used as an identifier. Internal output types (i.e. HTML and RSS)
	// can be overridden by providing a new definition for those types.
	Name string

	MediaType media.Type

	// Must be set to a value when there are two or more conflicting mediatype for the same resource.
	Path string

	// The base output file name used when not using "ugly URLs", defaults to "index".
	BaseName string

	// The protocol to use, i.e. "webcal://". Defaults to the protocol of the baseURL.
	Protocol string

	// IsPlainText decides whether to use text/template or html/template
	// as template parser.
	IsPlainText bool

	// Enable to ignore the global uglyURLs setting.
	NoUgly bool
}

func GetType(key string) (Type, bool) {
	found, ok := builtInTypes[key]
	if !ok {
		found, ok = builtInTypes[strings.ToLower(key)]
	}
	return found, ok
}

// TODO(bep) outputs rewamp on global config?
func GetTypes(keys ...string) (Types, error) {
	var types []Type

	for _, key := range keys {
		tpe, ok := GetType(key)
		if !ok {
			return types, fmt.Errorf("OutputType with key %q not found", key)
		}
		types = append(types, tpe)
	}

	return types, nil
}