text:
package main

import (
	"context"
	"errors"
	"fmt"
	"net/http"
	"os"
	"path/filepath"

	// Chi
	"github.com/go-chi/chi"
	"github.com/go-chi/chi/middleware"

	// Logging
	"go.uber.org/zap"
)

func main() {
	logger, err := zap.NewProduction()
	if err != nil {
		panic("failed to initialize logger")
	}

	r := chi.NewRouter()

	r.Use(
		middleware.Heartbeat("/health"),
		NewLoggerMiddleware(logger.Sugar()),
	)

	r.Get("/*", NewFileServer("/static", "index.html"))

	fmt.Println("Serving on port 3000")
	if err := http.ListenAndServe(":3000", r); err != nil {
		fmt.Println("BryrupTeater-Web quit unexpectedly")
	}
}

var loggerCtxKey = "logger"

func GetLogger(r *http.Request) (*zap.SugaredLogger, error) {
	logger, ok := r.Context().Value(loggerCtxKey).(*zap.SugaredLogger)
	if !ok {
		return nil, errors.New("no logger configured")
	}
	return logger, nil
}

func NewLoggerMiddleware(logger *zap.SugaredLogger) func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		fn := func (w http.ResponseWriter, r *http.Request) {
			r = r.WithContext(context.WithValue(r.Context(), loggerCtxKey,logger))

			next.ServeHTTP(w, r)
		}
		return http.HandlerFunc(fn)
	}
}

func NewFileServer(root, index string) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		logger, err := GetLogger(r)
		if err != nil {
			panic(err)
		}
		p := filepath.Join(root, filepath.Clean(r.URL.Path))
		if info, err := os.Stat(p); os.IsNotExist(err) {
			logger.Infow("file not found, serving index",
				zap.String("path", p),
				zap.String("index", filepath.Join(root, index)),
				)
			http.ServeFile(w, r, filepath.Join(root, index))
			return
		} else if info.IsDir() {
			logger.Infow("dir found, serving index",
				zap.String("path", p),
				zap.String("index", filepath.Join(root, index)),
			)
			http.ServeFile(w, r, filepath.Join(root, index))
			return
		}

		logger.Infow("serving file", zap.String("path", p))
		http.ServeFile(w, r, p)
	}
}

repository: lukaspj/go-spa

repo_name: lukaspj/go-spa


text:
require libpcap.inc

PR = "r6"
SRC_URI = "http://www.tcpdump.org/release/libpcap-${PV}.tar.gz"
SRC_URI += "file://aclocal.patch"
SRC_URI += "file://ieee80215-arphrd.patch"
SRC_URI += "file://ldflags.patch"
SRC_URI += "file://0001-Fix-some-problems-that-show-up-in-autoconf-2.64-and-.patch"

do_configure_prepend() {
	cat ${S}/aclocal.m4 >>${S}/acinclude.m4
}

do_compile () {
    oe_runmake
    rm -f *.o
    oe_runmake shared
}

do_install () {
    install -d ${D}${libdir}
    install -d ${D}${bindir}
    oe_runmake install DESTDIR=${D}
    oe_runmake install-shared DESTDIR=${D}
	oe_libinstall -a -so libpcap ${D}${libdir}

    install -d ${D}${includedir}/pcap
    install -m 0644 pcap/pcap.h ${D}${includedir}/pcap/pcap.h
    install -m 0644 pcap/namedb.h ${D}${includedir}/pcap/namedb.h
    install -m 0644 pcap/bpf.h ${D}${includedir}/pcap/bpf.h
}

SRC_URI[md5sum] = "9ad1358c5dec48456405eac197a46d3d"
SRC_URI[sha256sum] = "a214c4e1d7e22a758f66fe1d08f0ce41c3ba801a4c13dd1188e1e38288ac73c0"

license: MIT

repository: overo/overo-oe-natty

license_type: permissive

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
#-----------------------------------------------------------------------------
#                               DOXYGEN ?
#-----------------------------------------------------------------------------
find_package(Doxygen)
if(DOXYGEN_FOUND)
    configure_file(
        "${CMAKE_SOURCE_DIR}/cmake/in/Doxyfile.in.cmake"
        "${CMAKE_BINARY_DIR}/doc/Doxyfile"
        @ONLY
    )
    add_custom_target(
        doc
        COMMAND doxygen ${CMAKE_BINARY_DIR}/doc/Doxyfile
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
        COMMENT Doxygen is generating the documentation...
        VERBATIM
    )
else(DOXYGEN_FOUND)
    message(WARNING "Doxygen not found. Target doc will not be available")
endif(DOXYGEN_FOUND)

branch_name: refs/heads/master

gha_license_id: MIT

extension: cmake


text:
SUMMARY = "TI World packagegroup"
LICENSE = "MIT"

PACKAGE_ARCH = "${MACHINE_ARCH}"

inherit packagegroup

INSANE_SKIP:${PN} += "dev-deps"

CHROMIUM = ""
CHROMIUM:append:omap-a15 = "\
    chromium-ozone-wayland \
"
CHROMIUM:append:k3 = "\
    chromium-ozone-wayland \
"

EXTRABROWSERS = " \
    qtwebbrowser-examples \
    qtwebengine-qmlplugins \
    qtwebengine-examples \
"

PYTHON2APPS = " \
    ${@bb.utils.contains('DISTRO_FEATURES','opengl',"${EXTRABROWSERS}",'',d)} \
    ${@bb.utils.contains("BBFILE_COLLECTIONS","browser-layer",bb.utils.contains('DISTRO_FEATURES','wayland',"${CHROMIUM}",'',d),'',d)} \
"

DEVTOOLS = " \
    linux-libc-headers-dev \
    build-essential \
    packagegroup-core-tools-debug \
    git \
"

OPENCL = " \
    ${@bb.utils.contains('MACHINE_FEATURES','dsp','packagegroup-arago-tisdk-opencl ti-opencl','',d)} \
    ${@bb.utils.contains('MACHINE_FEATURES','dsp','packagegroup-arago-tisdk-opencl-extra','',d)} \
"

RDEPENDS:${PN} = "\
    packagegroup-arago-base \
    packagegroup-arago-console \
    packagegroup-arago-base-tisdk \
    ti-test \
    ${@bb.utils.contains('DISTRO_FEATURES','opengl','packagegroup-arago-tisdk-graphics','',d)} \
    ${@bb.utils.contains('DISTRO_FEATURES','opengl','packagegroup-arago-tisdk-gtk','',d)} \
    ${@bb.utils.contains('DISTRO_FEATURES','opengl','packagegroup-arago-tisdk-qte qt3d-examples','',d)} \
    ${@oe.utils.all_distro_features(d, "opencl", "${OPENCL}")} \
    packagegroup-arago-tisdk-connectivity \
    packagegroup-arago-tisdk-crypto \
    packagegroup-arago-tisdk-matrix \
    packagegroup-arago-tisdk-matrix-extra \
    packagegroup-arago-tisdk-multimedia \
    packagegroup-arago-tisdk-addons \
    packagegroup-arago-tisdk-addons-extra \
    ${@bb.utils.contains('DISTRO_FEATURES','opengl','packagegroup-arago-tisdk-hmi','packagegroup-arago-base-tisdk-server-extra',d)} \
    ${@bb.utils.contains("BBFILE_COLLECTIONS", "meta-python2", "${PYTHON2APPS}", "", d)} \
    ${DEVTOOLS} \
    ${@bb.utils.contains('TUNE_FEATURES', 'armv7a', 'valgrind', '', d)} \
    packagegroup-arago-misc \
    ti-analytics \
    ti-demos \
    ${PREFERRED_PROVIDER_virtual/docker} \
"

repository: rcn-ee/meta-arago

repo_name: rcn-ee/meta-arago


text:
package kafkaconfig

import (
	"testing"
	"time"

	"github.com/stretchr/testify/assert"
)

func TestTestConsumer(t *testing.T) {
	t.Parallel()

	c := TestConsumer(t)

	assert.Equal(t, []string{TestBrokerAddress}, c.Brokers)
	assert.Equal(t, time.Duration(500*time.Millisecond), c.CommitInterval)
	assert.Equal(t, "testGroup", c.GroupID)
	assert.Equal(t, time.Duration(150*time.Millisecond), c.HeartbeatInterval)
	assert.Equal(t, "testConsumer", c.ID)
	assert.Equal(t, OffsetBeginning, c.OffsetInitial)
	assert.Equal(t, ProtocolPlaintext, c.SecurityProtocol)
	assert.Equal(t, 1*time.Second, c.SessionTimeout)
	assert.Equal(t, []string{"testTopic"}, c.Topics)
}

license: ISC

repository: blendle/go-streamprocessor

repo_name: blendle/go-streamprocessor

gha_license_id: ISC

gha_language: Go

extension: go


text:
require xorg-proto-common.inc
DESCRIPTION = "DRI2 extension headers"
PR = "${INC_PR}.0"

SRC_URI[archive.md5sum] = "26f6515322ec50691584ac74291b4254"
SRC_URI[archive.sha256sum] = "1954a7e96d7fe70611c483836ed143e84a069eed6d3dab22c05a531bfb6da9e4"

repository: trini/openembedded

repo_name: trini/openembedded


text:
const path = require('path');
const fs = require('fs');

module.exports = function getClient(config) {
  let absPath = path.isAbsolute(config.module) ? config.module // already absolute path
    : path.resolve(process.cwd(), config.module) // try explicit first
  ;
  if (!fs.existsSync(absPath)) { // if not found, attempt to use node_modules
    absPath = path.resolve(process.cwd(), 'node_modules/' + config.module);
  }
  // no need to cache the `Client` module since `require` does this for us
  const mod = require(absPath);
  const Client = mod.default || mod; // support ES Modules & CommonJS
  // always create a unique instance of Client
  const instance = new Client(config.options || {});

  return instance;
};

gha_language: EJS

extension: js


text:
package interests

import (
	"net/http"

	"github.com/go-chi/chi"
	"github.com/go-chi/render"
	"github.com/orenkay/matcha/internal/api"
	"github.com/orenkay/matcha/internal/store"
)

func GetAll(s *store.Store) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		slug := chi.URLParam(r, "slug")
		interests, err := s.InterestService.AllBySlug(slug, 10)
		{
			if err != nil {
				render.Render(w, r, api.ErrInternal(err))
				return
			}
		}
		render.Render(w, r, api.DefaultResponse(http.StatusOK, interests))
	}
}

repository: coukou/matcha

repo_name: coukou/matcha


text:
# <ndk>/build/core/toolchains/x86_64-clang/setup.mk
set(_ANDROID_ABI_CLANG_TARGET "x86_64-none-linux-android")

string(APPEND _ANDROID_ABI_INIT_CFLAGS
  " -fPIC"
  )

include(Platform/Android/abi-common-Clang)

repository: REC-SPb-ETU/CMake

repo_name: REC-SPb-ETU/CMake

gha_language: C


text:
package usecase

import (
	"database/sql"

	"github.com/hack-boozer/boozer-api/photo"
	photoRepo "github.com/hack-boozer/boozer-api/photo/repository"
	"github.com/hack-boozer/boozer-api/post"
	postRepo "github.com/hack-boozer/boozer-api/post/repository"
	uuid "github.com/satori/go.uuid"
)

type postUsecase struct {
	postRepo  postRepo.PostRepository
	photoRepo photoRepo.PhotoRepository
}

// NewPostUsecase mount post usecase
func NewPostUsecase(postRepo postRepo.PostRepository, photoRepo photoRepo.PhotoRepository) PostUsecase {
	return &postUsecase{
		postRepo:  postRepo,
		photoRepo: photoRepo,
	}
}

// PostUsecase post usecase interface
type PostUsecase interface {
	Create(param *post.Create) (*post.Post, error)
	List() ([]*post.Media, error)
}

func formatPostPayload(param *post.Create) (*post.Post, []*photo.Photo) {
	postReq := &post.Post{
		ID:        uuid.NewV4(),
		AccountID: param.AccountID,
		Comment:   param.Comment,
		Rate:      sql.NullFloat64{Float64: param.Rate, Valid: true},
		UpdatedBy: param.AccountID,
	}
	photoReq := []*photo.Photo{}
	for _, p := range param.Photos {
		var req = &photo.Photo{
			PostID: postReq.ID,
			File:   p,
		}
		photoReq = append(photoReq, req)
	}
	return postReq, photoReq
}

repository: hack-boozer/boozer-api

repo_name: hack-boozer/boozer-api


text:
package main

import (
	"time"
)

// SparkleStats datatype
type SparkleStats struct {
	TopGiven []string `json:"top_given,omitempty"`
	TopGivers []string `json:"top_givers,omitempty"`
	FirstSparkle time.Time `json:"first_sparkle"`
	SimilarUsers []string `json:"similar_users,omitempty"`
	Categories []string `json:"categories"`
}

type SparkleGraph struct {
	Edges []SparkleGraphEdge `json:"edges"`
}

type SparkleGraphEdge struct {
	Sparkler string `json:"sparkler"`
	Sparklee string `json:"sparklee"`
	Weight int `json:"weight"`
}

func (s *SparkleDatabase) Graph() SparkleGraph {
  var sg SparkleGraph
  for _, v := range s.Sparkles {
    // See if the edge already exists. If it does, increment the score.
    // Otherwise, insert it.
    exists := false
    for k1, v1 := range sg.Edges {
      if (v.Sparkler == v1.Sparkler && v.Sparklee == v1.Sparklee) {
        sg.Edges[k1].Weight++
        exists = true
      }
    }

    if !exists {
      // Construct an edge
      var e SparkleGraphEdge
      e.Sparkler = v.Sparkler
      e.Sparklee = v.Sparklee
      e.Weight = 1
      sg.Edges = append(sg.Edges, e)
    }
  }
  return sg
}

func StatsForUser(user string) SparkleStats {
  var ss SparkleStats
  return ss
}


text:
%%% -*-BibTeX-*-
%%% Do NOT edit. File created by BibTeX with style
%%% ACM-Reference-Format-Journals [18-Jan-2012].

\begin{thebibliography}{9}

%%% ====================================================================
%%% NOTE TO THE USER: you can override these defaults by providing
%%% customized versions of any of these macros before the \bibliography
%%% command.  Each of them MUST provide its own final punctuation,
%%% except for \shownote{}, \showDOI{}, and \showURL{}.  The latter two
%%% do not use final punctuation, in order to avoid confusing it with
%%% the Web address.
%%%
%%% To suppress output of a particular field, define its macro to expand
%%% to an empty string, or better, \unskip, like this:
%%%
%%% \newcommand{\showDOI}[1]{\unskip}   % LaTeX syntax
%%%
%%% \def \showDOI #1{\unskip}           % plain TeX syntax
%%%
%%% ====================================================================

\ifx \showCODEN    \undefined \def \showCODEN     #1{\unskip}     \fi
\ifx \showDOI      \undefined \def \showDOI       #1{#1}\fi
\ifx \showISBNx    \undefined \def \showISBNx     #1{\unskip}     \fi
\ifx \showISBNxiii \undefined \def \showISBNxiii  #1{\unskip}     \fi
\ifx \showISSN     \undefined \def \showISSN      #1{\unskip}     \fi
\ifx \showLCCN     \undefined \def \showLCCN      #1{\unskip}     \fi
\ifx \shownote     \undefined \def \shownote      #1{#1}          \fi
\ifx \showarticletitle \undefined \def \showarticletitle #1{#1}   \fi
\ifx \showURL      \undefined \def \showURL       {\relax}        \fi
% The following commands are used for tagged output and should be
% invisible to TeX
\providecommand\bibfield[2]{#2}
\providecommand\bibinfo[2]{#2}
\providecommand\natexlab[1]{#1}
\providecommand\showeprint[2][]{arXiv:#2}

\bibitem[\protect\citeauthoryear{Bizopoulos, Sakellarios, Koutsouris,
  Iliopoulou, Michalis, and Fotiadis}{Bizopoulos et~al\mbox{.}}{2014}]%
        {bizopoulos2014randomly}
\bibfield{author}{\bibinfo{person}{Paschalis~A Bizopoulos},
  \bibinfo{person}{Antonis~I Sakellarios}, \bibinfo{person}{Dimitrios~D
  Koutsouris}, \bibinfo{person}{Dimitra Iliopoulou}, \bibinfo{person}{Lampros~K
  Michalis}, {and} \bibinfo{person}{Dimitrios~I Fotiadis}.}
  \bibinfo{year}{2014}\natexlab{}.
\newblock \showarticletitle{Randomly generated realistic vessel geometry using
  spline interpolation and 2D Perlin noise}. In
  \bibinfo{booktitle}{\emph{IEEE-EMBS International Conference on Biomedical
  and Health Informatics (BHI)}}. IEEE, \bibinfo{pages}{157--160}.
\newblock

\bibitem[\protect\citeauthoryear{Dewsbury, Nunn, Syrett, Tatum, and
  Thompson}{Dewsbury et~al\mbox{.}}{2016}]%
        {dewsbury2016scalable}
\bibfield{author}{\bibinfo{person}{Neall Dewsbury}, \bibinfo{person}{Aimie
  Nunn}, \bibinfo{person}{Matthew Syrett}, \bibinfo{person}{James Tatum}, {and}
  \bibinfo{person}{Tommy Thompson}.} \bibinfo{year}{2016}\natexlab{}.
\newblock \showarticletitle{Scalable level generation for 2d platforming
  games}. In \bibinfo{booktitle}{\emph{Proceedings of the FDG Workshop on
  Procedural Content Generation}}.
\newblock

\bibitem[\protect\citeauthoryear{Emilio, Moises, Gustavo, and Yago}{Emilio
  et~al\mbox{.}}{2010}]%
        {emilio2010}
\bibfield{author}{\bibinfo{person}{Martin Emilio}, \bibinfo{person}{Martinez
  Moises}, \bibinfo{person}{Recio Gustavo}, {and} \bibinfo{person}{Saez Yago}.}
  \bibinfo{year}{2010}\natexlab{}.
\newblock \showarticletitle{Pac-mAnt: Optimization based on ant colonies
  applied to developing an agent for Ms. Pac-Man}. In
  \bibinfo{booktitle}{\emph{Proceedings of the 2010 IEEE Conference on
  Computational Intelligence and Games}}. IEEE, \bibinfo{pages}{458--464}.
\newblock

\bibitem[\protect\citeauthoryear{Jain, Isaksen, Holmg{\aa}rd, and
  Togelius}{Jain et~al\mbox{.}}{2016}]%
        {jain2016autoencoders}
\bibfield{author}{\bibinfo{person}{Rishabh Jain}, \bibinfo{person}{Aaron
  Isaksen}, \bibinfo{person}{Christoffer Holmg{\aa}rd}, {and}
  \bibinfo{person}{Julian Togelius}.} \bibinfo{year}{2016}\natexlab{}.
\newblock \showarticletitle{Autoencoders for level generation, repair, and
  recognition}. In \bibinfo{booktitle}{\emph{Proceedings of the ICCC Workshop
  on Computational Creativity and Games}}.
\newblock

\bibitem[\protect\citeauthoryear{Liu, Togelius, P{\'e}rez-Li{\'e}bana, and
  Lucas}{Liu et~al\mbox{.}}{2017}]%
        {liu2017}
\bibfield{author}{\bibinfo{person}{Jialin Liu}, \bibinfo{person}{Julian
  Togelius}, \bibinfo{person}{Diego P{\'e}rez-Li{\'e}bana}, {and}
  \bibinfo{person}{Simon~M Lucas}.} \bibinfo{year}{2017}\natexlab{}.
\newblock \showarticletitle{Evolving game skill-depth using general video game
  {AI} agents}. In \bibinfo{booktitle}{\emph{2017 {IEEE} Congress on
  Evolutionary Computation {CEC}}}. IEEE, \bibinfo{pages}{2299--2307}.
\newblock

\bibitem[\protect\citeauthoryear{Pell}{Pell}{1992}]%
        {pell1992}
\bibfield{author}{\bibinfo{person}{Barney Pell}.}
  \bibinfo{year}{1992}\natexlab{}.
\newblock \showarticletitle{Metagame in symmetric chess-like games}.
\newblock  (\bibinfo{year}{1992}).
\newblock

\bibitem[\protect\citeauthoryear{Shaker, Liapis, Togelius, Lopes, and
  Bidarra}{Shaker et~al\mbox{.}}{2016}]%
        {shaker2016constructive}
\bibfield{author}{\bibinfo{person}{Noor Shaker}, \bibinfo{person}{Antonios
  Liapis}, \bibinfo{person}{Julian Togelius}, \bibinfo{person}{Ricardo Lopes},
  {and} \bibinfo{person}{Rafael Bidarra}.} \bibinfo{year}{2016}\natexlab{}.
\newblock \showarticletitle{Constructive generation methods for dungeons and
  levels}.
\newblock In \bibinfo{booktitle}{\emph{Procedural Content Generation in
  Games}}. \bibinfo{publisher}{Springer}, \bibinfo{pages}{31--55}.
\newblock

\bibitem[\protect\citeauthoryear{Smith, Treanor, Whitehead, and Mateas}{Smith
  et~al\mbox{.}}{2009}]%
        {smith2009rhythm}
\bibfield{author}{\bibinfo{person}{Gillian Smith}, \bibinfo{person}{Mike
  Treanor}, \bibinfo{person}{Jim Whitehead}, {and} \bibinfo{person}{Michael
  Mateas}.} \bibinfo{year}{2009}\natexlab{}.
\newblock \showarticletitle{Rhythm-based level generation for 2D platformers}.
  In \bibinfo{booktitle}{\emph{Proceedings of the 4th International Conference
  on Foundations of Digital Games}}. ACM, \bibinfo{pages}{175--182}.
\newblock

\bibitem[\protect\citeauthoryear{Van Der~Linden, Lopes, and Bidarra}{Van
  Der~Linden et~al\mbox{.}}{2013}]%
        {van2013procedural}
\bibfield{author}{\bibinfo{person}{Roland Van Der~Linden},
  \bibinfo{person}{Ricardo Lopes}, {and} \bibinfo{person}{Rafael Bidarra}.}
  \bibinfo{year}{2013}\natexlab{}.
\newblock \showarticletitle{Procedural generation of dungeons}.
\newblock \bibinfo{journal}{\emph{IEEE Transactions on Computational
  Intelligence and AI in Games}} \bibinfo{volume}{6}, \bibinfo{number}{1}
  (\bibinfo{year}{2013}), \bibinfo{pages}{78--89}.
\newblock

\end{thebibliography}

gha_language: TeX

extension: bbl


text:
include redeem.inc

LICENSE = "CC-BY-SA-2.0"
LIC_FILES_CHKSUM = "file://../LICENSE;md5=d91509a59f42bb5341a8af8295f28211"

S .= "/software"

RDEPENDS_${PN} = " \
    python-email \
    python-smbus \
    python-mmap \
    python-profile \
    python-spi \
    pypruss \
    libprussdrv \
    redeem-firmware \
    redeem-systemd \
    tty0tty \
    tty0tty-systemd \
"

inherit distutils

export BUILD_SYS
export HOST_SYS
export STAGING_INCDIR
export STAGING_LIBDIR

do_install_append () {
    install -d ${D}${bindir}
    install -d ${D}${bindir}/Replicape
    install -d ${D}${bindir}/Replicape/software
    install -d ${D}${bindir}/Replicape/software/config
    install -m 0644 ${S}/*.py ${D}${bindir}/Replicape/software
    install -m 0644 ${S}/*.c ${D}${bindir}/Replicape/software
    install -m 0644 ${S}/config/*.cfg ${D}${bindir}/Replicape/software/config
#    ln -s ${bindir}/Replicape/software/config/Thing.cfg ${bindir}/Replicape/software/config/default.cfg
}

FILES_${PN} += " \
	    ${bindir}/Replicape \
	    ${bindir}/Replicape/software \
            ${bindir}/Replicape/software/*.py \
            ${bindir}/Replicape/software/*.c \
	    ${bindir}/Replicape/software/config \
            ${bindir}/Replicape/software/config/*.cfg \
"

repository: moto-timo/meta-replicape

repo_name: moto-timo/meta-replicape

gha_language: BlitzBasic


text:
package schema

import (
	"strings"
	"time"
)

type UserGroup struct {
	Id          string    `gorethink:"id,omitempty"`
	Owner       string    `gorethink:"owner"`
	Name        string    `gorethink:"name"`
	Description string    `gorethink:"description"`
	Birthtime   time.Time `gorethink:"birthtime"`
	MTime       time.Time `gorethink:"mtime"`
	Access      string    `gorethink:"access"`
	Users       []string  `gorethink:"users"`
}

func NewUserGroup(owner, name string) UserGroup {
	now := time.Now()
	return UserGroup{
		Owner:       owner,
		Name:        name,
		Description: name,
		Access:      "private",
		Birthtime:   now,
		MTime:       now,
	}
}

type DataFile struct {
	Id              string    `gorethink:"id,omitempty"`
	Name            string    `gorethink:"name"`
	Access          string    `gorethink:"access"`
	MarkedForReview bool      `gorethink:"marked_for_review"`
	Reviews         []string  `gorethink:"reviews"`
	Birthtime       time.Time `gorethink:"birthtime"`
	MTime           time.Time `gorethink:"mtime"`
	ATime           time.Time `gorethink:"atime"`
	Tags            []string  `gorethink:"tags"`
	MyTags          []string  `gorethink:"mytags"`
	Description     string    `gorethink:"description"`
	Notes           []string  `gorethink:"description"`
	Owner           string    `gorethink:"owner"`
	Process         string    `gorethink:"process"`
	Machine         string    `gorethink:"machine"`
	Checksum        string    `gorethink:"checksum"`
	Size            int64     `gorethink:"size"`
	Location        string    `gorethink:"location"`
	MediaType       string    `gorethink:"mediatype"`
	Conditions      []string  `gorethink:"conditions"`
	Text            string    `gorethink:"text"`
	MetaTags        []string  `gorethink:"metatags"`
	DataDirs        []string  `gorethink:"datadirs"`
	Parent          string    `gorethink:"parent"`
}

func NewDataFile(name, access, owner string) DataFile {
	now := time.Now()
	return DataFile{
		Name:        name,
		Access:      access,
		Owner:       owner,
		Description: name,
		Birthtime:   now,
		MTime:       now,
		ATime:       now,
	}
}

type Project struct {
	Id          string    `gorethink:"id,omitempty"`
	Name        string    `gorethink:"name"`
	Description string    `gorethink:"description"`
	DataDir     string    `gorethink:"datadir"`
	Owner       string    `gorethink:"owner"`
	Birthtime   time.Time `gorethink:"birthtime"`
	MTime       time.Time `gorethink:"mtime"`
	Notes       []string  `gorethink:"notes"`
	Tags        []string  `gorethink:"tags"`
	Reviews     []string  `gorethink:"reviews"`
	MyTags      []string  `gorethink:"mytags"`
}

func NewProject(name, datadir, owner string) Project {
	now := time.Now()
	return Project{
		Name:      name,
		DataDir:   datadir,
		Owner:     owner,
		Birthtime: now,
		MTime:     now,
	}
}

type DataDir struct {
	Id              string    `gorethink:"id,omitempty"`
	Access          string    `gorethink:"access"`
	Owner           string    `gorethink:"owner"`
	MarkedForReview bool      `gorethink:"marked_for_review"`
	Name            string    `gorethink:"name"`
	DataFiles       []string  `gorethink:"datafiles"`
	DataParams      []string  `gorethink:"dataparams"`
	Users           []string  `gorethink:"users"`
	Tags            []string  `gorethink:"tags"`
	MyTags          []string  `gorethink:"mytags"`
	Parent          string    `gorethink:"parent"`
	Reviews         []string  `gorethink:"reviews"`
	Birthtime       time.Time `gorethink:"birthtime"`
	MTime           time.Time `gorethink:"mtime"`
	ATime           time.Time `gorethink:"atime"`
}

func NewDataDir(name, access, owner, parent string) DataDir {
	now := time.Now()
	return DataDir{
		Id:        owner + "$" + strings.Replace(name, "/", "_", -1),
		Owner:     owner,
		Name:      name,
		Parent:    parent,
		Access:    access,
		Users:     []string{owner},
		Birthtime: now,
		MTime:     now,
		ATime:     now,
	}
}

type User struct {
	Id          string    `gorethink:"id,omitempty"`
	Name        string    `gorethink:"name"`
	Email       string    `gorethink:"email"`
	Fullname    string    `gorethink:"fullname"`
	Password    string    `gorethink:"password"`
	ApiKey      string    `gorethink:"apikey"`
	Birthtime   time.Time `gorethink:"birthtime"`
	MTime       time.Time `gorethink:"mtime"`
	Avatar      string    `gorethink:"avatar"`
	Description string    `gorethink:"description"`
	Affiliation string    `gorethink:"affiliation"`
	HomePage    string    `gorethink:"homepage"`
	Notes       []string  `gorethink:"notes"`
}

func NewUser(name, email, password, apikey string) User {
	now := time.Now()
	return User{
		Name:      name,
		Email:     email,
		Password:  password,
		ApiKey:    apikey,
		Birthtime: now,
		MTime:     now,
	}
}

repository: materials-commons/base

repo_name: materials-commons/base