digitalkaoz/issues-bundle

digitalkaoz/issues 的 Symfony 扩展包

安装: 27

依赖: 0

建议: 0

安全: 0

星标: 1

关注者: 3

分支: 0

开放问题: 0

语言:JavaScript

类型:symfony-bundle

0.1.2 2014-10-16 10:37 UTC

This package is not auto-updated.

Last update: 2024-09-10 02:17:48 UTC


README

#IssuesBundle

digitalkaoz/issues 的 Symfony 集成

##安装

我们当然使用 composer 进行安装

$ composer require digitalkaoz/issues-bundle

在 Kernel 中启用它

<?php
// app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            //...
            new Rs\IssuesBundle\RsIssuesBundle(),
            //...
        );
    }

##配置

###问题跟踪器简单地引入以下结构到您的 config.yml 或(对于敏感数据)在您的 parameters.yml

    rs_issues:
        github:
            - digitalkaoz/issues                                             # concrete repo
            - phpcr/*                                                        # all user/org repos
            - symfony/[Console|Debug]+$                                      # only symfony/Console and symfony/Debug
            - doctrine/(?!common|lexer)([a-z0-9\.-]+)$                       # all but doctrine/common and doctrine/lexer
        jira:
            - https://jira.com PROJKEY [USER] [PASSWORD]                     # username and password are optional
        gitlab:
            - http://gitlab.com/api/v3/ johnsmith/* TOKEN                    # the repo patterns are the same like for github
            - http://gitlab.com/api/v3/ gitlab/[gitlab\-shell|Testme] TOKEN
            - http://gitlab.com/api/v3/ root/(?!six)([a-zA-Z0-9\.-]+)$ TOKEN

###存储适配器如果您使用 elasticsearch 作为存储,您应该导入所需的映射并配置 elastica

#app/config/config.yml
imports:
    - { resource: @RsIssuesBundle/Resources/config/es_mapping.yml }

fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }

###路由

包含路由

rs_issues:
    resource: "@RsIssuesBundle/Resources/config/routing.xml"
    prefix:   /issues

##使用

如果您使用 elasticsearch 作为适配器存储(目前唯一支持的一种)您有两种方法将所有存储库信息同步到存储中

$ app/console fos:elastica:populate # preferred way

对于其他存储适配器

$ app/console issues:sync

然后您可以访问 http://yourdomain.com/issues(或您用路由前缀替换的任何内容)

##扩展

###实现新的存储适配器

简单地实现 Storage 接口

<?php
interface Storage
{
    /**
     * remove old issues and projects
     */
    public function cleanup();

    /**
     * save a Project and all its Issues
     *
     * @param Project $project
     */
    public function saveProject(Project $project);

    /**
     * get all imported Projects
     *
     * @return Project[]
     */
    public function getProjects();

    /**
     * get all Issues for the provided Project-Id
     *
     * @param  string  $projectId
     * @return Issue[]
     */
    public function getIssues($projectId);
}

之后创建服务并将其标记为默认存储

<service id="rs_issues.storage.my_storage" class="%rs_issues.storage.my_storage.class%">
    <tag name="rs_issues.storage" />
</service>

###实现新的同步器

如果您实现了一个新的跟踪器(带有项目和问题)您需要编写一个新的同步器。只需实现 Synchronizer 接口。

<?php
interface Synchronizer
{
    /**
     * synchronizes all Projects and Issues from the Tracker into the Storage
     *
     * @param \Closure $cb
     */
    public function synchronize($cb = null);

    /**
     * set the repositories to synchronize
     *
     * @param array $repos
     */
    public function setRepos(array $repos);
}

之后创建服务并标记它

<service id="rs_issues.synchronizer.mytracker" class="%rs_issues.synchronizer.mytracker.class%">
    <argument type="service" id="rs_issues.storage" />
    <tag name="rs_issues.synchronizer" />
</service>

###构建前端代码

我们使用 BootstrapSass 进行样式表处理,以及 ReactJs + CortexJs 进行 JavaScript 部分。

我们在本仓库提供 预编译 文件,但我们不保证它们是最新的。如果您愿意尝试,请按照以下步骤操作

简单地将以下依赖项包含在您的 bower.json

{
    "dependencies": {
        "bootstrap-sass-official":  "~3.2.0",
        "modernizr":                "~2.8.3",
        "respond":                  "~1.4.2",
        "octicons":                 "~2.1.2"
    }
}

并在您的 package.json 中包含以下依赖项

{
    "dependencies": {
        "cortexjs":     "^0.6.0",
        "marked":       "^0.3.2",
        "moment":       "^2.8.3",
        "react":        "^0.11.2",
        "reqwest":      "^1.1.2",
        "xss":          "^0.1.12"
    }
}

之后您应该运行这两个包管理器

$ npm install
$ bower install

现在您应该编译所有内容

我们不会详细介绍这一点。对于处理 Sass 文件,可以使用 Gulp 或 Grunt,甚至 assetic 都可以做到。

处理 JS 的工具选择众多

在这个仓库中提供了一个示例 bower.jsonpackage.jsongulpfile.js。您应该将它们复制到项目的根目录。