Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/config/structs.go

263 lignes
10 Kio
Go
Brut Vue normale Historique

package config
import (
"strings"
)
// Config : Configuration for DB, I2P, Fetcher, Go Server and Translation
type Config struct {
Host string `json:"host" yaml:"host,omitempty"`
Port int `json:"port" yaml:"port,omitempty"`
DBType string `json:"db_type" yaml:"db_type,omitempty"`
Environment string `json:"environment" yaml:"environment,omitempty"`
AuthTokenExpirationDay int `json:"auth_token_expiration" yaml:"auth_token_expiration,omitempty"`
EnableSecureCSRF bool `json:"enable_secure_csrf" yaml:"enable_secure_csrf,omitempty"`
DescriptionLength int `json:"description_length" yaml:"description_length,omitempty"`
CommentLength int `json:"comment_length" yaml:"comment_length,omitempty"`
// DBParams will be directly passed to Gorm, and its internal
// structure depends on the dialect for each db type
DBParams string `json:"db_params" yaml:"db_params,omitempty"`
DBLogMode string `json:"db_logmode" yaml:"db_logmode,omitempty"`
Version string `json:"version" yaml:"version,omitempty"`
Build string `yaml:"-"`
// web address config
WebAddress WebAddressConfig `yaml:"web_address,flow,omitempty"`
// cookies config
Cookies CookiesConfig `yaml:"cookies,flow,omitempty"`
// tracker scraper config (required)
Scrape ScraperConfig `json:"scraper" yaml:"scraper,flow,omitempty"`
// cache config
Cache CacheConfig `json:"cache" yaml:"cache,flow,omitempty"`
// search config
Search SearchConfig `json:"search" yaml:"search,flow,omitempty"`
// optional i2p configuration
I2P *I2PConfig `json:"i2p" yaml:"i2p,flow"`
// filesize fetcher config
MetainfoFetcher MetainfoFetcherConfig `json:"metainfo_fetcher" yaml:"metainfo_fetcher,flow,omitempty"`
// internationalization config
I18n I18nConfig `json:"i18n" yaml:"i18n,flow,omitempty"`
// torrents config
Torrents TorrentsConfig `yaml:"torrents,flow,omitempty"`
// user config
Users UsersConfig `yaml:"users,flow,omitempty"`
// navigation config
Navigation NavigationConfig `yaml:"navigation,flow,omitempty"`
// log config
Log LogConfig `yaml:"log,flow,omitempty"`
// email config
Email EmailConfig `yaml:"email,flow,omitempty"`
// models config
Models ModelsConfig `yaml:"models,flow,omitempty"`
// Default Theme config
DefaultTheme DefaultThemeConfig `yaml:"default_theme,flow,omitempty"`
}
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
// Tags Config struct for tags in torrent
2017-07-28 20:43:22 +02:00
type Tags struct {
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
MaxWeight float64 `yaml:"max_weight,omitempty"`
Default string `yaml:"default,omitempty"`
Types TagTypes `yaml:"types,flow,omitempty"`
2017-07-28 20:43:22 +02:00
}
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
// TagType Config struct for tag type in torrent
type TagType struct {
Name string `yaml:"name"`
Defaults ArrayString `yaml:"defaults"`
Field string `yaml:"field"`
}
type TagTypes []TagType
// WebAddressConfig : Config struct for web addresses
type WebAddressConfig struct {
Nyaa string `yaml:"nyaa,omitempty"`
Sukebei string `yaml:"sukebei,omitempty"`
Status string `yaml:"status,omitempty"`
}
// CookiesConfig : Config struct for session cookies
type CookiesConfig struct {
DomainName string `yaml:"domain_name,omitempty"`
MaxAge int `yaml:"max_age,omitempty"`
HashKey string `yaml:"hash_key,omitempty"`
EncryptionKey string `yaml:"encryption_key,omitempty"`
}
// CacheConfig is config struct for caching strategy
type CacheConfig struct {
Dialect string `yaml:"dialect,omitempty"`
URL string `yaml:"url,omitempty"`
Size float64 `yaml:"size,omitempty"`
}
// I2PConfig : Config struct for I2P
type I2PConfig struct {
Name string `json:"name" yaml:"name,omitempty"`
Addr string `json:"samaddr" yaml:"addr,omitempty"`
Keyfile string `json:"keyfile" yaml:"keyfile,omitempty"`
}
// I18nConfig : Config struct for translation
type I18nConfig struct {
Directory string `json:"translations_directory" yaml:"directory,omitempty"`
DefaultLanguage string `json:"default_language" yaml:"default_language,omitempty"`
}
// ScrapeConfig : Config struct for Scraping
type ScrapeConfig struct {
URL string `json:"scrape_url" yaml:"url,omitempty"`
Name string `json:"name" yaml:"name,omitempty"`
IntervalSeconds int64 `json:"interval" yaml:"interval,omitempty"`
}
// ScraperConfig : Config struct for Scraper
type ScraperConfig struct {
Addr string `json:"bind" yaml:"addr,omitempty"`
NumWorkers int `json:"workers" yaml:"workers,omitempty"`
IntervalSeconds int64 `json:"default_interval" yaml:"default_interval,omitempty"`
Trackers []ScrapeConfig `json:"trackers" yaml:"trackers,omitempty"`
}
// TrackersConfig ; Config struct for Trackers
type TrackersConfig struct {
Default ArrayString `yaml:"default,flow,omitempty"`
NeededTrackers []int `yaml:"needed,flow,omitempty"`
}
// TorrentsConfig : Config struct for Torrents
type TorrentsConfig struct {
Status []bool `yaml:"status,omitempty,omitempty"`
SukebeiCategories map[string]string `yaml:"sukebei_categories,omitempty"`
CleanCategories map[string]string `yaml:"clean_categories,omitempty"`
EnglishOnlyCategories ArrayString `yaml:"english_only_categories,omitempty"`
NonEnglishOnlyCategories ArrayString `yaml:"non_english_only_categories,omitempty"`
AdditionalLanguages ArrayString `yaml:"additional_languages,omitempty"`
FileStorage string `yaml:"filestorage,omitempty"`
StorageLink string `yaml:"storage_link,omitempty"`
CacheLink string `yaml:"cache_link,omitempty"`
UploadsDisabled bool `yaml:"uploads_disabled,omitempty"`
AdminsAreStillAllowedTo bool `yaml:"admins_are_still_allowed_to,omitempty"`
TrustedUsersAreStillAllowedTo bool `yaml:"trusted_users_are_still_allowed_to,omitempty"`
Trackers TrackersConfig `yaml:"trackers,flow,omitempty"`
Order string `yaml:"order,omitempty"`
Sort string `yaml:"sort,omitempty"`
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
Tags Tags `yaml:"tags,flow,omitempty"`
}
// UsersConfig : Config struct for Users
type UsersConfig struct {
DefaultUserSettings map[string]bool `yaml:"default_notifications_settings,flow,omitempty"`
}
// NavigationConfig : Config struct for Navigation
type NavigationConfig struct {
TorrentsPerPage int `yaml:"torrents_per_page,omitempty"`
MaxTorrentsPerPage int `yaml:"max_torrents_per_page,omitempty"`
}
// MetainfoFetcherConfig : Config struct for metainfo fetcher
type MetainfoFetcherConfig struct {
QueueSize int `json:"queue_size" yaml:"queue_size,omitempty"`
Timeout int `json:"timeout" yaml:"timeout,omitempty"`
MaxDays int `json:"max_days" yaml:"max_days,omitempty"`
BaseFailCooldown int `json:"base_fail_cooldown" yaml:"base_fail_cooldown,omitempty"`
MaxFailCooldown int `json:"max_fail_cooldown" yaml:"max_fail_cooldown,omitempty"`
WakeUpInterval int `json:"wake_up_interval" yaml:"wake_up_interval,omitempty"`
2017-06-02 12:03:23 +02:00
UploadRateLimitKiB int `json:"upload_rate_limit" yaml:"upload_rate_limit,omitempty"`
DownloadRateLimitKiB int `json:"download_rate_limit" yaml:"download_rate_limit,omitempty"`
FetchNewTorrentsOnly bool `json:"fetch_new_torrents_only" yaml:"fetch_new_torrents_only,omitempty"`
}
// LogConfig : Config struct for Logs
type LogConfig struct {
AccessLogFilePath string `yaml:"access_log_filepath,omitempty"`
AccessLogFileExtension string `yaml:"access_log_fileextension,omitempty"`
AccessLogMaxSize int `yaml:"access_log_max_size,omitempty"`
AccessLogMaxBackups int `yaml:"access_log_max_backups,omitempty"`
AccessLogMaxAge int `yaml:"access_log_max_age,omitempty"`
ErrorLogFilePath string `yaml:"error_log_filepath,omitempty"`
ErrorLogFileExtension string `yaml:"error_log_fileextension,omitempty"`
ErrorLogMaxSize int `yaml:"error_log_max_size,omitempty"`
ErrorLogMaxBackups int `yaml:"error_log_max_backups,omitempty"`
ErrorLogMaxAge int `yaml:"error_log_max_age,omitempty"`
}
// EmailConfig : Config struct for email
type EmailConfig struct {
SendEmail bool `yaml:"send_email,omitempty"`
From string `yaml:"from,omitempty"`
TestTo string `yaml:"test_to,omitempty"`
Host string `yaml:"host,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Port int `yaml:"port,omitempty"`
Timeout int `yaml:"timeout,omitempty"`
}
// ModelsConfig : Config struct for models
type ModelsConfig struct {
LastOldTorrentID uint `yaml:"last_old_torrent_id,omitempty"`
TorrentsTableName string `yaml:"torrents_table_name,omitempty"`
ReportsTableName string `yaml:"reports_table_name,omitempty"`
CommentsTableName string `yaml:"comments_table_name,omitempty"`
UploadsOldTableName string `yaml:"uploads_old_table_name,omitempty"`
FilesTableName string `yaml:"files_table_name,omitempty"`
NotificationsTableName string `yaml:"notifications_table_name,omitempty"`
ActivityTableName string `yaml:"activities_table_name,omitempty"`
ScrapeTableName string `yaml:"scrape_table_name,omitempty"`
}
type DefaultThemeConfig struct {
Theme string `yaml:"theme,omitempty"`
Dark string `yaml:"dark,omitempty"`
Forced string `yaml:"forced,omitempty"`
}
// SearchConfig : Config struct for search
type SearchConfig struct {
OAuth API [done] (#1275) * Initial Commit for OAuth API This builds and run and return the right error. Need to test it and then adding all users as possible client * Added mising dependency * just compile already... * Fixing template test * Imrpovements Moved db stuff in models Added some tests Added form in modpanel to add/update a client Added controllers for add/update of client * Added Forms + speed improvements Controller oauth client listing + html Controller oauth client delete + messages Messages on comment delete New ES config that disable ES if set to false. Improve load speed on local development Fix a load config bug Fix index admin & translation string sign_out broken by @ewhal * Sanitize empty strig in form array + css Multiple empty array of strings are sanitized for the oauth client create form Added some css for the form display * Upload and Create form works * Fix splitting response types * Removing required on secret when updating * fix travis error * Fix travis template test * Update dependency * Moved to jinzhu instead of azhao * randomizen secret on creation * Final touch on oath api improved display name fix grant form csrf fix login csrf on oauth * Fix gorm test * fix template test * Fixing deleted dependency issue * Make travis faster * Fix typo * Fix csrf for api calls * This shouldn't be exempt * Removing hard coded hash @ewhal Don't forget to replace the hash in tokens.go with another one * Added an example on how to use OAuth middleware * Renamed fosite utils to oauth2 utils
2017-07-28 05:46:40 +02:00
EnableElasticSearch bool `yaml:"enable_es,omitempty"`
ElasticsearchAnalyzer string `yaml:"es_analyze,omitempty"`
ElasticsearchIndex string `yaml:"es_index,omitempty"`
ElasticsearchType string `yaml:"es_type,omitempty"`
}
// ArrayString is an array of string with some easy functions
type ArrayString []string
// Contains check if there is a string in the array of string
func (ar ArrayString) Contains(str string) bool {
for _, s := range ar {
if s == str {
return true
}
}
return false
}
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
// Join regroup the array of string in one string separated by commas
func (ar ArrayString) Join() string {
return strings.Join(ar, ",")
}
Tag Search + Tests + Search slight refactor [DONE] (#1342) * Tag Search + Tests + Search slight refactor First commit improving search. Different struct have their own file with their tests. This way of separating struct by files is inspired by the go packages I've seen so far. Added new behaviour as discussed in #1334 * fix fallback to ES * Added some comments to explain PG fallback + log err moved * Refactored search Nearly fully covered WhereParams struct has disappeared for Query struct instead In DB model, we use an interface implementing Query struct methods * 1rst Refactor of Tags (WTF already?!) Prepare Tags for the refactored system. Now there will be descriptive tags for a particular release (ecchi, BDSM, ....) and typed tags. Typed tags are tags relevant to all torrents and can be limited to some input value. For example, video quality is a typed tag limited to some values (hd, full hd, sd, ...). In the same way, anidbid is also a typed tag but doesn't have default values. Furthermore, the location storage of tags have changed, now accepted descriptive tags are stored in the torrents table in the column "tags" and they are separated by commas. In the opposite, accepted typed tags can have have their own column in the torrents table. For example, anidbid, vndbid will populate the column DbID when accepted. On the other hand, videoquality will populate the same way as descriptive tags. This behaviour depends on the callbackOnType function in tag/helpers.go * fix for modtools :') * Added anidb, vndb, dlsite & vmdb id fields in torrent model. Tags don't have an accepted field anymore. Accepted Tags are in torrent.AcceptedTags and non-accepted ones in torrrent.Tags. New Helper + New Changelog for translation string. * New upload/edit form for torrent tags. Now the inputs are dynamically generated by the helper tag_form. No more modal window in those form, only inputs. Support of tags in API New translation string for the link to the modal on torrent view. More comments in the functions for tags * Improving how config for tags work. Adding a test on them with understandable messages. Config for tags have now a Field attribute which is linked to the Torrent model. For example anidbid tag type has now a AnidbID field in config which is the name of the field in torrent model (AnidbID). Every new tag type need to have a field attribute with its counterpart in torrent Model. Fixing some errors * Fix compile error + Tests Errors * Improve performance by caching the list of tags with an index Adding/removing tags works/tested New translation strings TODO: test/fix adding tag on upload/edit * Mini fix to display video quality + tags works/tested on modo edit * Fix editing tags on modpanel * Edit tags works * Add translation string * Add search backend for tags. ?tags=xxx,eee,ddd ?anidb=21 ?vndb=23 ?vgmdb=24 ?vq=full_hd * Fix Ajax tag Removal&Add * Added form for descriptive tags * Forgot to add the link between database and form for descriptive tags. * Adding the increase/decrease pantsu for descriptive tags * Fix #1370 * When you actually forgot to commit files after having forgotten commits
2017-08-22 03:48:10 +02:00
var tagtypes map[string]int
func initTagTypes() {
tagtypes = make(map[string]int)
for key, tagtype := range Get().Torrents.Tags.Types {
tagtypes[tagtype.Name] = key
}
}
// Get return the tag type
func (ty TagTypes) Get(tagType string) TagType {
if len(tagtypes) == 0 {
initTagTypes()
}
if tagID, ok := tagtypes[tagType]; ok {
return ty[tagID]
}
return TagType{}
}