Пример #1
0
 public function package($package_name)
 {
     $this->load->model('spark');
     $spark = Spark::getInfo($package_name);
     if (!$spark) {
         show_404();
     }
     $versions = $spark->getVersions(TRUE);
     $this->load->view('rss/versions', array('spark' => $spark, 'versions' => $versions));
 }
Пример #2
0
 /**
  * Attach a user to a given team based on their invitation.
  *
  * @param  string  $invitationId
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function attachUserToTeamByInvitation($invitationId, $user)
 {
     $userModel = get_class($user);
     $inviteModel = get_class((new $userModel())->invitations()->getQuery()->getModel());
     $invitation = (new $inviteModel())->where('token', $invitation)->first();
     if ($invitation) {
         $invitation->team->users()->attach([$user->id], ['role' => Spark::defaultRole()]);
         $user->switchToTeam($invitation->team);
         $invitation->delete();
     }
 }
Пример #3
0
 /**
  * Rate a package
  */
 public function rate($package_name)
 {
     $this->load->model('spark');
     $this->load->model('rating');
     $spark = Spark::getInfo($package_name);
     if (!$spark) {
         show_404();
     }
     if ($this->input->post('rating') && UserHelper::isLoggedIn()) {
         $this->load->model('rating');
         $this->rating->rate(UserHelper::getId(), $spark->id, $this->input->post('rating'));
     } else {
         $this->error("You are not logged in, or your request was invalid");
     }
     $this->success(array('ratings' => $this->rating->getRatings($spark->id)));
 }
Пример #4
0
 /**
  * The search page call
  */
 function index()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $submit = $this->input->post('submit');
     $search_results = array();
     $search_term = $this->input->get_post('term', TRUE);
     if ($submit) {
         if ($this->form_validation->run('search')) {
             $this->load->model('spark');
             $search_results = Spark::search($search_term);
         } else {
             UserHelper::setNotice('Whoops. There were some errors. Check below and re-submit!');
         }
     }
     $data['search_term'] = $search_term;
     $data['sparks'] = $search_results;
     echo json_encode($data);
 }
Пример #5
0
 /**
  * The API call to get a spec
  * @param string $package_name
  * @param string $version
  * @param string $format
  */
 public function spec($package_name, $version)
 {
     $this->load->model('spark');
     $this->load->model('contributor');
     $this->load->model('download');
     $spark = Spark::get($package_name, $version);
     if (!$spark) {
         show_404();
     }
     $spark->spark_home = base_url() . 'packages/' . $spark->name . '/show';
     $spark->contributor = $spark->getContributor();
     $spark->dependencies = $spark->getDependencies();
     # Omit the password hash
     unset($spark->contributor->password);
     # Do this?
     $spark->recordInstall();
     Download::recordDownload('spec');
     $this->output->set_output(json_encode(array('success' => true, 'spec' => $spark)));
 }
Пример #6
0
 /**
  * The POST call to add a version to a package
  *  Redirect to the package page on success
  */
 public function add()
 {
     $submit = $this->input->post('submit');
     if ($submit) {
         $this->load->library('form_validation');
         $this->load->model('version');
         $this->load->model('spark');
         $insert = elements(array('spark_id', 'tag'), $_POST);
         if ($this->form_validation->run('add-version')) {
             if (Version::insert($insert)) {
                 UserHelper::setNotice("Version added!");
             }
         } else {
             UserHelper::setNotice("Try to enter a valid tag!", FALSE);
         }
         $spark = Spark::getById($insert['spark_id']);
         redirect(base_url() . 'packages/' . $spark->name . '/show');
     }
     show_error("Whatcha doin' here?");
 }
Пример #7
0
    <title>@yield('title', 'Spark')</title>

    <!-- Fonts -->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet' type='text/css'>
    <link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css' rel='stylesheet' type='text/css'>

    <!-- CSS -->
    <link href="/css/app.css" rel="stylesheet">

    <!-- Scripts -->
    @yield('scripts', '')

    <!-- Global Spark Object -->
    <script>
        window.Spark = <?php 
echo json_encode(array_merge(Spark::scriptVariables(), []));
?>
;
    </script>
</head>
<body class="with-navbar">
    <div>
        <!-- Navigation -->
        @if (Auth::check())
            @include('spark::nav.blade.user')
        @else
            @include('spark::nav.guest')
        @endif

        <!-- Main Content -->
        @yield('content')
Пример #8
0
# Set the right directories
define('IS_BOOTSTRAP', TRUE);
$webroot = dirname(__FILE__) . '/../';
chdir($webroot);
# Load up CodeIgniter
require_once $webroot . 'index.php';
# Load up the spark libs
$CI =& get_instance();
$CI->load->model('spark');
$CI->load->model('contributor');
$CI->load->spark('spark-sdk/1.0');
$CI->load->spark('markdown/1.1');
# Set the spark path
$spark_path = WEBROOT . config_item('archive_path');
# Grab the unverified sparks
$sparks = Spark::getUnverified();
# A place to hold successfull/unsuccessful
$successful = array();
$unsuccessful = array();
# Roll through each unverified spark
foreach ($sparks as $spark) {
    $handle = md5(uniqid());
    $tmp = "/tmp/{$handle}";
    # Create a temporary holding place
    mkdir($tmp);
    chdir($tmp);
    # Pull down a copy
    if ($spark->repository_type == 'hg') {
        `hg clone -r{$spark->tag} {$spark->base_location} {$tmp}`;
    } elseif ($spark->repository_type == 'git') {
        $token = 'spark-' . $spark->id . '-' . time();
Пример #9
0
// TWo-Factor Authentication Routes...
$router->get('login/token', 'Auth\\AuthController@getToken');
$router->post('login/token', 'Auth\\AuthController@postToken');
// Registration Routes...
$router->get('register', 'Auth\\AuthController@getRegister');
$router->post('register', 'Auth\\AuthController@postRegister');
// Password Routes...
$router->get('password/email', 'Auth\\PasswordController@getEmail');
$router->post('password/email', 'Auth\\PasswordController@postEmail');
$router->get('password/reset/{token}', 'Auth\\PasswordController@getReset');
$router->post('password/reset', 'Auth\\PasswordController@postReset');
// User API Routes...
$router->get('spark/api/users/me', 'API\\UserController@getCurrentUser');
// Team API Routes...
if (Spark::usingTeams()) {
    $router->get('spark/api/teams/invitations', 'API\\InvitationController@getPendingInvitationsForUser');
    $router->get('spark/api/teams/roles', 'API\\TeamController@getTeamRoles');
    $router->get('spark/api/teams/{id}', 'API\\TeamController@getTeam');
    $router->get('spark/api/teams', 'API\\TeamController@getAllTeamsForUser');
    $router->get('spark/api/teams/invitation/{code}', 'API\\InvitationController@getInvitation');
}
// Subscription API Routes...
if (count(Spark::plans()) > 0) {
    $router->get('spark/api/subscriptions/plans', 'API\\SubscriptionController@getPlans');
    $router->get('spark/api/subscriptions/coupon/{code}', 'API\\SubscriptionController@getCoupon');
    $router->get('spark/api/subscriptions/user/coupon', 'API\\SubscriptionController@getCouponForUser');
}
// Stripe Routes...
if (count(Spark::plans()) > 0) {
    $router->post('stripe/webhook', 'Stripe\\WebhookController@handleWebhook');
}
Пример #10
0
 function __construct($data) {
     if (!self::git_installed()) throw new SparkException('You have to have git to install this spark.');
     parent::__construct($data);
     $this->tag = $this->version;
 }
Пример #11
0
<script type="text/javascript" charset="utf-8">
	$('#lazy_profile').available(function() {
		$.post("/ajax/contributors/get_profile_box", function(data) {
			$("#lazy_profile").html(data);
		});
	});
</script>

<?php 
$this->load->model('spark');
$featured_sparks = Spark::getLatestOf(3, TRUE);
$official_sparks = Spark::getLatestOf(3, NULL, TRUE);
?>

<div class="page-left">
	
	<div class="login-box clearfix">
        <div id="lazy_profile"></div>
	</div>
	
    <!-- Temporary Twitter -->
    
	<div class="info-box clearfix">
        <!-- <h2><a style="color:#33ccff;letter-spacing:3px;" href="http://twitter.com/getsparks">@getsparks</a></h2> -->
        <iframe allowtransparency="true" frameborder="0" scrolling="no"
          src="http://platform.twitter.com/widgets/follow_button.html?screen_name=getsparks&text_color=ffffff&link_color=00aeff"
          style="width:200px; height:20px;"></iframe>
        <p style="padding-top:12px;">Hey! Keep up to date with the project through its beta and public launch by following <a style="color:white;" href="http://twitter.com/getsparks">@getsparks</a>.</p>
        <a href="http://twitter.com/share" class="twitter-share-button" data-url="http://getsparks.org" data-text="GetSparks — The CodeIgniter Package Manager" data-count="horizontal" data-via="getsparks" data-related="_kennyk_">Tweet</a>
	</div>
    
Пример #12
0
 /**
  * Show the spark search page
  */
 function search()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $submit = $this->input->post('submit');
     $search_results = array();
     $search_term = $this->input->post('term');
     $data['ratings'] = array();
     if ($submit) {
         if ($this->form_validation->run('search')) {
             $this->load->model('spark');
             $this->load->model('rating');
             $search_results = Spark::search($search_term);
             $ids = array();
             foreach ($search_results as $s) {
                 $ids[] = $s->id;
             }
             $data['ratings'] = $this->rating->getRatingsFromList($ids);
         } else {
             UserHelper::setNotice('Whoops. There were some errors. Check below and re-submit!');
         }
     }
     $data['search_term'] = $search_term;
     $data['sparks'] = $search_results;
     $data['description'] = 'These are the most recently registered sparks with at least one release.';
     $this->load->view('search/listing', $data);
 }
Пример #13
0
 // API Token Refresh...
 $router->put('/spark/token', 'TokenController@refresh');
 // Users...
 $router->get('/user/current', 'UserController@current');
 $router->put('/user/last-read-announcements-at', 'UserController@updateLastReadAnnouncementsTimestamp');
 // Notifications
 $router->get('/notifications/recent', 'NotificationController@recent');
 $router->put('/notifications/read', 'NotificationController@markAsRead');
 // Settings Dashboard...
 $router->get('/settings', 'Settings\\DashboardController@show');
 // Profile Contact Information...
 $router->put('/settings/contact', 'Settings\\Profile\\ContactInformationController@update');
 // Profile Photo...
 $router->post('/settings/photo', 'Settings\\Profile\\PhotoController@store');
 // Teams...
 if (Spark::usesTeams()) {
     // General Settings...
     $router->get('/settings/teams/roles', 'Settings\\Teams\\TeamMemberRoleController@all');
     $router->get('/settings/teams/{team}', 'Settings\\Teams\\DashboardController@show');
     $router->get('/teams', 'TeamController@all');
     $router->get('/teams/current', 'TeamController@current');
     $router->get('/teams/{team_id}', 'TeamController@show');
     $router->post('/settings/teams', 'Settings\\Teams\\TeamController@store');
     $router->post('/settings/teams/{team}/photo', 'Settings\\Teams\\TeamPhotoController@update');
     $router->put('/settings/teams/{team}/name', 'Settings\\Teams\\TeamNameController@update');
     // Invitations...
     $router->get('/settings/teams/{team}/invitations', 'Settings\\Teams\\MailedInvitationController@all');
     $router->post('/settings/teams/{team}/invitations', 'Settings\\Teams\\MailedInvitationController@store');
     $router->get('/settings/invitations/pending', 'Settings\\Teams\\PendingInvitationController@all');
     $router->get('/invitations/{invitation}', 'InvitationController@show');
     $router->post('/settings/invitations/{invitation}/accept', 'Settings\\Teams\\PendingInvitationController@accept');
Пример #14
0
 function __construct($data) {
     parent::__construct($data);
     $this->temp_file = $this->temp_path . '.zip';
     $this->archive_url = property_exists($this->data, 'archive_url') ? $this->data->archive_url : null;
 }
Пример #15
0
                    </div>

                    <div class="splash-feature-heading">
                        add quizzes and track student performance
                    </div>

                    <div class="splash-feature-text">
                        Keep track of student performance.
                    </div>
                </div>
            </div>
        </div>

        <!-- Pricing Variables -->
        <?php 
$plans = Spark::plans()->monthly()->active();
?>

        <?php 
switch (count($plans)) {
    case 0:
    case 1:
        $columns = 'col-md-6 col-md-offset-3';
        break;
    case 2:
        $columns = 'col-md-6';
        break;
    case 3:
        $columns = 'col-md-4';
        break;
    case 4:
Пример #16
0
 /**
  * Get the number of total installs in GetSparks.org history
  * @return int
  */
 public static function getGlobalInstallCount()
 {
     $CI =& get_instance();
     $CI->load->model('spark');
     return Spark::getGlobalInstallCount() + config_item('install_count_base');
 }
Пример #17
0
 function __construct($data) {
     parent::__construct($data);
     $this->tag = $this->version;
 }