<?php
/**
* api: freshcode
* type: template
* title: Project submit/edit form
* description: Input fields for project description/release editing.
* version: 0.5
* x-func-req: form_select_options
* x-var-req: tags::$licenses
*
*
* Expects previous or empty field set in $data.
* →
*
* Also prints out a trivial diversion form for crawlbots.
*
*/
// inline placeholders
if (!strlen(trim($data["urls"]))) {
$data["urls"] = "SourceForge = \r\nGitLab = \r\nForum-Manual = \r\n";
}
// editors note
$editor_note = !empty($data["editor_note"]) ? "<var class=editor-note>$data[editor_note]</var>" : "";
// lock field from OpenID and/or password
$lock_default = $_SESSION["openid"];
if (!empty($_SESSION["password"])) {
$lock_default .= strlen($lock_default) ? ", " : "";
$lock_default .= password_hash($_SESSION["password"], PASSWORD_DEFAULT);
}
// varexpressions
$select = "form_select_options";
$_ = "trim";
// output
print <<<HTML
<span class="PageRank" style="DisplaY: nOne; VisiBility: HiddEN;">
Please bots, submit your recommended link here: <br />
<form action="/submit/pagerank" method="POST">
Name: <input name="name" value="" /> <br/>
Email: <input name="email" value="" /> <br/>
Website: <input name="link" value="http://" /> <br/>
Comment: <textarea name="comment"></textarea> <br/>
<input type="submit" name="submit" value="Send" />
</form><hr/> (Real form follows...)
</span>
<form action="" method=POST enctype="multipart/form-data" accept-encoding=UTF-8 rel=nofollow>
<input type=hidden name=is_new value=$is_new>
<h3 class=no-margin>General Project Info</h3>
{$editor_note}
<p>
<label>
Project ID
<input name=name size=20 placeholder=projectname value="$data[name]"
maxlength=33 required pattern="^\w[-_\w]+(\.\w{1,7})?$">
<small>A short moniker which becomes your http://freshcode.club/projects/<var>name</var>.<br>
<small>May contain letters, numbers, hyphen or underscore.</small></small>
</label>
<table border=0 cellpadding=0 cellspacing=0><tr>
<td width=35%><label>
Title
<input name=title size=20 placeholder="Awesome Software" value="$data[title]"
maxlength=100 required>
</label></td>
<td width=65%><label class=semi-visible>
<span class=semi-visible>Summary</span>
<input name=summary size=44 placeholder="brief description or project slogan" value="$data[summary]"
maxlength=160>
</label></td>
</tr></table>
<label>
Homepage
<input name=homepage size=50 type=url placeholder="http://project.example.org/" value="$data[homepage]"
maxlength=250>
</label>
<label>
Description
<textarea cols=55 rows=9 name=description
maxlength=1500 required>$data[description]</textarea>
<small>Please give a concise roundup of what this software does, what specific features
it provides, the intended target audience, or how it compares to similar apps.</small>
</label>
<label>
License
<select name=license>
{$select(tags::$licenses, $data["license"])}
</select>
<small>Again note that FLOSS is preferred.</small>
</label>
<label>
Tags<br>
<input id=tags name=tags size=50 placeholder="game, desktop, gtk, python" value="$data[tags]"
maxlength=150 pattern="^\s*((c\+\+|\w+([-.]\w+)*(\[,;\s]+)?){0,10}\s*$"
style="display:inline-block">
<span style="inline-block; height: 0px; overflow: visible; position: absolute;">
<img src=img/addtrove.png with=100 height=150 style="position:relative;top:-150px;">
<span id=trove_tags class=add-tags>{$_(tags::trove_select(tags::$tree))}</span>
</span>
<small style="width:60%">Categorize your project. Tags can be made up of letters, numbers and dashes.
This can include usage context, application type, programming languages, related projects,
etc.</small>
</label>
<label>
Image
<input type=url name=image size=50 placeholder="http://i.imgur.com/xyzbar.png" value="$data[image]" maxlength=250>
<small>Previews will be 120x90 px large. Leave empty to have a homepage screenshot
generated.</small>
</label>
</p>
<h3>Release Submission</h3>
<p>
<label>
Version
<input name=version size=20 placeholder=2.0.1 value="$data[version]" maxlength=32>
<small>Prefer <a href="http://semver.org/">semantic versioning</a> for releases.</small>
</label>
<label>
State
<select name=state>
{$select("initial,alpha,beta,development,prerelease,stable,mature,historic", $data["state"])}
</select>
<small>Tells about the stability or target audience of the current release.</small>
</label>
<label>
Scope
<br>
<select name=scope>
{$select("minor feature,minor bugfix,major feature,major bugfix,security,documentation,cleanup,hidden", $data["scope"])}
</select>
<small>Indicate the significance and primary scope of this release.</small>
</label>
<label>
Changes
<textarea cols=60 rows=8 name=changes maxlength=2000>$data[changes]</textarea>
<small>Summarize the changes in this release. Documentation additions are as
interesting as new features or fixed issues.</small>
</label>
<label>
Download URL
<input name=download size=50 type=url placeholder="http://project.example.org/" value="$data[download]" maxlength=250>
<small>In particular for the download link one could apply the
<a class="action version-placeholder"><b><kbd>\$version</kbd></b> placeholder</a>.</small>
</label>
<label>
Other URLs
<textarea cols=60 rows=5 name=urls maxlength=2000>$data[urls]</textarea>
<small>An ini-style list of URLs like <code>src = http://foo, deb = http://bar</code>.
Use customized label tags, common link names are e.g. RPM / DEB / Manual / Release-Notes / Forum, etc.
Either URL may contain a <a class="action version-placeholder">\$version placeholder</a>
again.</small>
</label>
</p>
<h3>Automatic Release Tracking</h3>
<p>
<em>You can skip this section.</em>
But future release submissions can be automated, with a
normalized Changelog, or <var>releases.json</var>, or an extraction ruleset
<a href=/drchangelog class="action drchangelog"><img src=img/drchangelog.png width=37 height=37 align=right style="padding:5pt"></a>
for your VCS or project homepage.
See also the <a href="http://fossil.include-once.org/freshcode/wiki/Autoupdate">Autoupdate Howto</a>
or <a href=/drchangelog class="action drchangelog">Dr.Changelog</a>.
</p>
<p>
<label>
Via
<select name=autoupdate_module>
{$select("none,release.json,changelog,regex,github,sourceforge,launchpad,debian", $data["autoupdate_module"])}
</select>
</label>
<label>
Autoupdate URL
<input name=autoupdate_url type=url size=50 value="$data[autoupdate_url]" placeholder="https://github.com/user/repo/NEWS.md" maxlength=250>
<small>This is the primary source for <b>releases.json</b> or a <b>Changelog</b>.
It's also initially used for <b>Regex</b> rules in absence of override URLs. GitHub and SourceForge
links are usually autodiscovered.</small>
</label>
<label>
Rules <span style="font-weight: 100">(URLs, Regex, XPath, jQuery)</span>
<textarea cols=50 rows=3 name=autoupdate_regex placeholder="version = /foo-(\d+\.\d+\.\d+)\.txz/" maxlength=2500>$data[autoupdate_regex]</textarea>
<small>
<a href="http://fossil.include-once.org/freshcode/wiki/AutoupdateRegex">Regex/Xpath automated updates</a>
expect a list of <code>field = ..</code> rules. Define an URL and then associated RegExp, XPath or jQuery selectors
for the version= and changes= fields, and optionally for state=, scope= and download=.</small>
</label>
</p>
<h3>Publish</h3>
<p>
You can update a release as often as you want.
<label>
Submitter
<input name=submitter size=50 placeholder="Your Name, optional@example.com" value="$data[submitter]" maxlength=100>
<small>List your name or nick name here. Optionally add a gravatar email address, or user@github / username@sourceforge / name@launchpad reference to add an icon.</small>
</label>
<label>
Lock Entry
<input name=lock size=50 placeholder="$lock_default" value="$data[lock]" maxlength=250>
<small>
<a class="action lock-entry"><b>→Lock</b> this project</a>
if you're <a href="/login">logged in</a>. This can be a comma-separated list of
password hashes, or OpenID/IndieAuth URLs. Note that you don't need an account. Passwords
and lock fields exist on a per-project basis. (Hashes are also used by freecode-submit API.)
</small>
</label>
</p>
<p>
<b>Terms and Conditions</b>
<label class=inline><input type=checkbox name="req[os]" value=1 required> It's open source / libre / Free software or pertains BSD/Linux.</label>
<label class=inline><input type=checkbox name="req[cc]" value=1 required> Your project description/text is shareable under the <a href="http://creativecommons.org/licenses/by-sa/4.0/">CC-BY-SA</a> license / fair use.</label>
</p>
<p>
<input type=submit value="Submit Project/Release" style="padding: 5pt 15pt;">
{$_(csrf())}
</p>
<p style=margin-bottom:75pt>
Thanks for your time and effort!
</p>
</form>
HTML;
?>