Пример #1
0
 public function convert($content)
 {
     $content = $this->markdown->transform($content);
     if (!is_null($this->smartypants)) {
         $content = $this->smartypants->transform($content);
     }
     $content = trim($content);
     return $content;
 }
Пример #2
0
 public function toHTML($text)
 {
     $text = $this->preTransformText($text);
     $text = MarkdownExtra::defaultTransform($text);
     $text = SmartyPants::defaultTransform($text);
     return $this->postTransformText($text);
 }
Пример #3
0
function generate()
{
    $pages = array('index.html', 'documentation.html', 'license.html', 'support.html', 'getinvolved.html', 'search.html', 'install.html', 'providers.html', 'plugins.html', 'developer-ref-user-authentication.html', 'developer-ref-user-profile.html', 'developer-ref-user-contacts.html', 'developer-ref-user-status.html', 'developer-ref-exceptions.html', 'developer-ref-full-api.html', 'developer-ref-extend-hybridauth.html', 'developer-ref-migrating.html');
    $REQUEST_URI = $_SERVER['REQUEST_URI'];
    $basename = basename($REQUEST_URI);
    if ('index.html' == $basename) {
        echo file_get_contents('index.html');
    } elseif (in_array($basename, $pages)) {
        $header = file_get_contents('common/header.html');
        $markdown = file_get_contents(str_replace('.html', '.md', $basename));
        $body = MarkdownExtra::defaultTransform($markdown);
        $footer = file_get_contents('common/footer.html');
        $html = $header . $body . $footer;
        $html = str_replace(array('#__TITLE#', '#__FILENAME#', '#__PAGEURL#'), array(ucfirst(trim(str_replace(array('developer-ref-', '-', '.html'), ' ', $basename))), $basename, 'https://hybridauth.github.io/hybridauth/' . $basename), $html);
        echo $html;
    }
}
Пример #4
0
 public function loadIssues()
 {
     $projs = list_project(null, null, "published = 1");
     foreach ($projs as $proj) {
         Makiavelo::puts("Getting issues for : " . $proj->name);
         $data = GithubAPI::getProjectIssues($proj->owner()->name, $proj->name, "open");
         foreach ($data as $issue) {
             $iss = new Issue();
             $iss->title = $issue->title;
             $iss->body = MarkdownExtra::defaultTransform($issue->body);
             $iss->created_at = $issue->created_at;
             $iss->updated_at = $issue->updated_at;
             $iss->url = $issue->html_url;
             $iss->number = $issue->number;
             $iss->project_id = $proj->id;
             Makiavelo::puts("Saving issue: #" . $iss->number);
             save_issue($iss);
         }
     }
 }
Пример #5
0
 public function content_edit_verify($APP)
 {
     $APP->set('MODUL_ID', 52);
     $USER_RIGHTS = parent::checkUserModulRights($APP->get('MODUL_ID'), $APP->get('LOGIN_USER_RIGHTS'));
     if ($USER_RIGHTS == false) {
         $APP->get('CONSTRUCTR_LOG')->write('User ' . $APP->get('SESSION.username') . ' missing USER-RIGHTS for modul ' . $APP->get('MODUL_ID'));
         $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/no-rights');
     }
     $POST_CSRF = $APP->get('POST.csrf');
     $POST_ADDITIVE = $APP->get('POST.csrf_additive');
     $POST_TRIPPLE_ADDITIVE = $APP->get('POST.csrf_tripple_additive');
     if ($POST_CSRF != '') {
         if ($POST_CSRF != $APP->get('SESSION.csrf')) {
             $APP->get('CONSTRUCTR_LOG')->write('FORM CSRF DON\'T MATCH: ' . $POST_USERNAME);
             $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/logout');
         }
     }
     if ($POST_ADDITIVE != '') {
         if ($POST_ADDITIVE != $APP->get('SESSION.additive')) {
             $APP->get('CONSTRUCTR_LOG')->write('FORM ADDITIVE DON\'T MATCH: ' . $POST_USERNAME);
             $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/logout');
         }
     }
     if ($POST_TRIPPLE_ADDITIVE != '') {
         if ($POST_TRIPPLE_ADDITIVE != $APP->get('SESSION.tripple_additive')) {
             $APP->get('CONSTRUCTR_LOG')->write('FORM TRIPPLE ADDITIVE DON\'T MATCH: ' . $POST_USERNAME);
             $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/logout');
         }
     }
     if ($POST_TRIPPLE_ADDITIVE != $POST_ADDITIVE . $POST_CSRF) {
         $APP->get('CONSTRUCTR_LOG')->write('FORM TRIPPLE ADDITIVE COMPARISON DON\'T MATCH: ' . $POST_USERNAME);
         $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/logout');
     }
     $PAGE_ID = filter_var($APP->get('PARAMS.page_id'), FILTER_SANITIZE_NUMBER_INT);
     $APP->set('PAGE_ID', $PAGE_ID);
     $CONTENT_ID = filter_var($APP->get('PARAMS.content_id'), FILTER_SANITIZE_NUMBER_INT);
     $APP->set('CONTENT_ID', $CONTENT_ID);
     $EDIT_CONTENT_RAW = $APP->get('POST.edit_content_raw');
     $EDIT_CONTENT_HTML = MarkdownExtra::defaultTransform($EDIT_CONTENT_RAW);
     $EDIT_CONTENT_MAPPING = $APP->get('POST.edit_content_mapping');
     if ($PAGE_ID != '' && $CONTENT_ID != '') {
         if ($EDIT_CONTENT_MAPPING != '' && $EDIT_CONTENT_MAPPING != '666') {
             $APP->set('EDIT_CONTENT', $APP->get('DBCON')->exec(['UPDATE constructr_content SET constructr_content_content_raw=:EDIT_CONTENT_RAW,constructr_content_content_html=:EDIT_CONTENT_HTML,constructr_content_tpl_id_mapping=:EDIT_CONTENT_MAPPING WHERE constructr_content_page_id=:PAGE_ID AND constructr_content_id=:CONTENT_ID LIMIT 1;'], [[':PAGE_ID' => $PAGE_ID, ':EDIT_CONTENT_RAW' => $EDIT_CONTENT_RAW, ':EDIT_CONTENT_HTML' => $EDIT_CONTENT_HTML, ':CONTENT_ID' => $CONTENT_ID, ':EDIT_CONTENT_MAPPING' => $EDIT_CONTENT_MAPPING]]));
         } else {
             $APP->set('EDIT_CONTENT', $APP->get('DBCON')->exec(['UPDATE constructr_content SET constructr_content_content_raw=:EDIT_CONTENT_RAW,constructr_content_content_html=:EDIT_CONTENT_HTML,constructr_content_tpl_id_mapping=:EDIT_CONTENT_MAPPING WHERE constructr_content_page_id=:PAGE_ID AND constructr_content_id=:CONTENT_ID LIMIT 1;'], [[':PAGE_ID' => $PAGE_ID, ':EDIT_CONTENT_RAW' => $EDIT_CONTENT_RAW, ':EDIT_CONTENT_HTML' => $EDIT_CONTENT_HTML, ':CONTENT_ID' => $CONTENT_ID, ':EDIT_CONTENT_MAPPING' => '']]));
         }
         parent::clean_up_cache($APP);
         $APP->set('EDIT', 'success');
         $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/content/' . $PAGE_ID . '/?edit=success');
     } else {
         $APP->set('EDIT', 'no-success');
         $APP->reroute($APP->get('CONSTRUCTR_BASE_URL') . '/constructr/content/' . $PAGE_ID . '/?edit=no-success');
     }
 }
Пример #6
0
    	</div>
    	<div class="span6 pull-left">
    		<h2>Commits activity</h2>
    		<div class="well " id="commits-stats" style="height:300px;">
    		</div>
    	</div>
    	<div class="clearfix"></div>
    	<div class="span12">
    		<h2>Pull requests activity</h2>
    		<div class="well " id="pull-stats" style="height:400px;">
    		</div>
    	</div>
    </div>
    <div class="well tab-pane" id="readme">
    <?php 
echo MarkdownExtra::defaultTransform($this->project->readme);
?>
    </div>
    <div class="well tab-pane" id="faqs">
        <?php 
echo $this->renderView("_faqs");
?>
    </div>
</div>
<script type="text/javascript" src="/javascripts/highcharts/js/highcharts.js"></script>
<script >
var commit_readings = [];
var pulls = [];
var popularity = [];
<?php 
//TODO: Improve following code...
Пример #7
0
 public function __construct()
 {
     /*
     		$this->block_gamut += array(
     			"doFencedFigures"   => 7
     		);
     */
     $this->document_gamut += array("doClearBreaks" => 100);
     parent::__construct();
 }
Пример #8
0
 /**
 Loads all projects and queries Githubs API for new data
 on stars and forks
 */
 public function generateAction()
 {
     $projects = list_project(null, null, "published = 1");
     Makiavelo::info("=== Starting stats process ===");
     foreach ($projects as $proj) {
         $proj_name = $proj->name;
         $usr_name = $proj->owner()->name;
         $dev = $proj->owner();
         Makiavelo::info("==== Querying for {$usr_name}/{$proj_name}");
         Makiavelo::info("Last Update: " . $proj->updated_at);
         if (strstr($proj->updated_at, date("Y-m-d"))) {
             Makiavelo::info("Skiping project");
             continue;
             //Avoid duplicated entries
         }
         $data = GithubAPI::queryProjectData($usr_name, $proj_name);
         //We update the dev's avatar if needed
         if ($data->owner->avatar_url != $dev->avatar_url) {
             $dev->avatar_url = $data->owner->avatar_url;
             save_developer($dev);
         }
         //Calculate the commits for today
         $commits_today = 0;
         $today = date("Y-m-d");
         /*
         Makiavelo::info("========================");
         Makiavelo::info(print_r($data->commits, true));
         Makiavelo::info("========================");
         exit();
         */
         foreach ($data->commits as $commit) {
             $commit_date = $commit->commit->committer->date;
             $commit_date = explode("T", $commit_date);
             $commit_date = $commit_date[0];
             $pc = load_project_commit_where("sha = '" . $commit->sha . "'");
             if ($pc == null) {
                 //We make sure we haven't yet saved this commit
                 $project_commit = new ProjectCommit();
                 $project_commit->project_id = $proj->id;
                 $project_commit->committer = $commit->committer->login;
                 $project_commit->commit_message = $commit->commit->message;
                 $project_commit->sha = $commit->sha;
                 $project_commit->commit_date = $commit_date;
                 save_project_commit($project_commit);
             }
             if ($commit_date == $today) {
                 $commits_today++;
             }
         }
         $new_pulls_today = $closed_pulls_today = $merged_pulls_today = 0;
         $total_pulls = 0;
         $total_merged_pulls = 0;
         foreach ($data->pulls as $pull) {
             $created_data = explode("T", $pull->created_at);
             $closed_data = explode("T", $pull->closed_at);
             $merged_data = explode("T", $pull->merged_at);
             $total_pulls++;
             if ($pull->merged_at) {
                 $total_merged_pulls++;
             }
             if ($created_data[0] == $today) {
                 $new_pulls_today++;
             }
             if ($closed_data[0] == $today) {
                 $closed_pulls_today++;
             }
             if ($merged_data[0] == $today) {
                 $merged_pulls_today++;
             }
         }
         if ($total_pulls > 0) {
             $proj->pr_acceptance_rate = $total_merged_pulls / $total_pulls * 100;
         } else {
             $proj->pr_acceptance_ratec = -1;
         }
         $delta_stars = $data->watchers - $proj->stars;
         $delta_forks = $data->forks - $proj->forks;
         //if($delta_stars != 0 || $delta_forks != 0) {
         Makiavelo::info("==== Delta found, saving...");
         //We also update the project
         $proj->stars = $data->watchers;
         $proj->forks = $data->forks;
         $proj->readme = $data->readme;
         $proj->description = $data->description;
         $proj->open_issues = $data->open_issues;
         save_project($proj);
         $pd = new ProjectDelta();
         $pd->forks = $data->forks;
         $pd->delta_forks = $delta_forks;
         $pd->open_issues = $data->open_issues;
         $pd->closed_issues = $data->closed_issues;
         $pd->stars = $data->watchers;
         $pd->delta_stars = $delta_stars;
         $pd->project_id = $proj->id;
         $pd->commits_count = $commits_today;
         $pd->new_pulls = $new_pulls_today;
         $pd->closed_pulls = $closed_pulls_today;
         $pd->merged_pulls = $merged_pulls_today;
         $pd->sample_date = date("Y-m-d H:i:s");
         if (save_project_delta($pd)) {
             Makiavelo::info("===== Delta saved! ");
             Makiavelo::info(print_r($pd, true));
         } else {
             Makiavelo::info("===== ERROR saving delta");
         }
         //}
         delete_issues_by_project_id($proj->id);
         foreach ($data->open_issues_list as $issue) {
             $iss = new Issue();
             $iss->title = $issue->title;
             $iss->body = MarkdownExtra::defaultTransform($issue->body);
             $iss->created_at = $issue->created_at;
             $iss->updated_at = $issue->updated_at;
             $iss->url = $issue->html_url;
             $iss->number = $issue->number;
             $iss->project_id = $proj->id;
             if (save_issue($iss)) {
                 Makiavelo::info("===== Issue saved! ");
             } else {
                 Makiavelo::info("===== ERROR saving issue::" . mysql_error());
             }
         }
     }
 }
Пример #9
0
 public function grabHistoricData()
 {
     $proj_name = $this->name;
     $usr_name = $this->owner()->name;
     Makiavelo::info("==== Querying for {$usr_name}/{$proj_name}");
     $g_data = GithubAPI::queryProjectData($usr_name, $proj_name);
     $this->readme = $g_data->readme;
     //Makiavelo::puts("Updating project...");
     save_project($this);
     $data = array();
     foreach ($g_data->commits as $commit) {
         $commit_date = $commit->commit->committer->date;
         $commit_date = explode("T", $commit_date);
         $commit_date = $commit_date[0];
         $date_idx = intval(str_replace("-", "", $commit_date));
         if (!isset($data[$date_idx]) || !isset($data[$date_idx]['commits'])) {
             $data[$date_idx] = array("commits" => 1);
         } else {
             $data[$date_idx]['commits']++;
         }
         $pc = load_project_commit_where("sha = '" . $commit->sha . "'");
         if ($pc == null) {
             //We make sure we haven't yet saved this commit
             $project_commit = new ProjectCommit();
             $project_commit->project_id = $this->id;
             $project_commit->committer = $commit->committer->login;
             $project_commit->commit_message = $commit->commit->message;
             $project_commit->sha = $commit->sha;
             $project_commit->commit_date = $commit_date;
             save_project_commit($project_commit);
         }
     }
     foreach ($g_data->pulls as $pull) {
         $created_data = explode("T", $pull->created_at);
         $closed_data = explode("T", $pull->closed_at);
         $merged_data = explode("T", $pull->merged_at);
         $created_idx = intval(str_replace("-", "", $created_data[0]));
         $merged_idx = intval(str_replace("-", "", $merged_data[0]));
         $closed_idx = intval(str_replace("-", "", $closed_data[0]));
         if (!isset($data[$created_idx]) || !isset($data[$created_idx]['new_pulls'])) {
             $data[$created_idx]['new_pulls'] = 1;
         } else {
             $data[$created_idx]['new_pulls']++;
         }
         if ($merged_idx != 0) {
             if (!isset($data[$merged_idx]) || !isset($data[$merged_idx]['merged_pulls'])) {
                 $data[$merged_idx]['merged_pulls'] = 1;
             } else {
                 $data[$merged_idx]['merged_pulls']++;
             }
         }
         if ($closed_idx != 0) {
             if (!isset($data[$closed_idx]) || !isset($data[$closed_idx]['closed_pulls'])) {
                 $data[$closed_idx]['closed_pulls'] = 1;
             } else {
                 $data[$closed_idx]['closed_pulls']++;
             }
         }
     }
     foreach ($data as $date => $stats) {
         $year = substr($date, 0, 4);
         $month = substr($date, 4, 2);
         $day = substr($date, 6, 2);
         $str_date = $year . "-" . $month . "-" . $day;
         $pd = new ProjectDelta();
         $pd->forks = -99;
         $pd->delta_forks = -99;
         $pd->stars = -99;
         $pd->delta_stars = -99;
         $pd->project_id = $this->id;
         $pd->commits_count = isset($stats['commits']) ? $stats['commits'] : 0;
         $pd->new_pulls = isset($stats['new_pulls']) ? $stats['new_pulls'] : 0;
         $pd->closed_pulls = isset($stats['closed_pulls']) ? $stats['closed_pulls'] : 0;
         $pd->merged_pulls = isset($stats['merged_pulls']) ? $stats['merged_pulls'] : 0;
         $pd->sample_date = $str_date;
         if (save_project_delta($pd)) {
             Makiavelo::info("===== Delta saved! ");
         } else {
             Makiavelo::info("===== ERROR saving delta::" . mysql_error());
         }
     }
     foreach ($g_data->open_issues_list as $issue) {
         $iss = new Issue();
         $iss->title = $issue->title;
         $iss->body = MarkdownExtra::defaultTransform($issue->body);
         $iss->created_at = $issue->created_at;
         $iss->updated_at = $issue->updated_at;
         $iss->url = $issue->html_url;
         $iss->number = $issue->number;
         $iss->project_id = $this->id;
         if (save_issue($iss)) {
             Makiavelo::info("===== Issue saved! ");
         } else {
             Makiavelo::info("===== ERROR saving issue::" . mysql_error());
         }
     }
 }
Пример #10
0
function ExplainMarkdownExtra($path)
{
    $text = file_get_contents($path);
    return MarkdownExtra::defaultTransform($text);
}