nit.git
7 years agonitc: explicitly cast long to int
Alexis Laferrière [Wed, 8 Feb 2017 08:32:19 +0000 (03:32 -0500)]
nitc: explicitly cast long to int

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agonitc: fix large int constants
Alexis Laferrière [Wed, 8 Feb 2017 07:14:32 +0000 (02:14 -0500)]
nitc: fix large int constants

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agotext: use UInt32 to manipulate chars
Alexis Laferrière [Wed, 8 Feb 2017 06:51:21 +0000 (01:51 -0500)]
text: use UInt32 to manipulate chars

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocore: invert dependencies between `text` and `fixed_ints`
Alexis Laferrière [Wed, 8 Feb 2017 06:27:09 +0000 (01:27 -0500)]
core: invert dependencies between `text` and `fixed_ints`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agoMerge: nitunit: fix before and after methods
Jean Privat [Mon, 6 Feb 2017 13:39:51 +0000 (08:39 -0500)]
Merge: nitunit: fix before and after methods

Before and after method were not actually called in the test suite process.

This PR enables the compilation and run of these methods.

The new behavior is: if the `before_module` test case fails, all the test cases and the `after_module` are skipped and marked as failed.

Pull-Request: #2359
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agoMerge: macOS: update realtime lib for Sierra
Jean Privat [Mon, 6 Feb 2017 13:39:19 +0000 (08:39 -0500)]
Merge: macOS: update realtime lib for Sierra

The latest version of macOS, Sierra, defines the functions `clock_gettime` and `clock_getres` which were previously missing. This PR adds support for Sierra while preserving compatibility with El Capitan using a simple heuristic to either use the system provided functions or define them locally.

Reported-by: Marie-Pier Lessard @mplessard

Pull-Request: #2358
Reviewed-by: Jean-Philippe Caissy <jpcaissy@piji.ca>

7 years agoMerge: nitc: inject importation
Jean Privat [Mon, 6 Feb 2017 13:39:02 +0000 (08:39 -0500)]
Merge: nitc: inject importation

Extends the nitc code so a phase can inject new submodules.

The main new method the this PR is `ModelBuilder::inject_module_subimportation` that must be used during the analysis on a module.

Up to now, the module hierarchy was fixed and built by the loader before any phases are run.
The basic way was: 1. load the main module, 2. load its imported modules recursively and build the hierarchy, 3. run the phases on all the loaded modules from the most general to the most specific (top-down)
Now the phases can also extends the module hierarchy while running some phases.
This cause the following changes:
* `run_phase` use a work-list (instead of a simple loop)
* new modules can pop up even for the main module of a program, so a fictive main module is always created
* conditional_importations is extended to be used to by inject_module_subimportation.

Pull-Request: #2357
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agotests: add tests for nitunit before and after module
Alexandre Terrasa [Fri, 3 Feb 2017 06:56:06 +0000 (01:56 -0500)]
tests: add tests for nitunit before and after module

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/test_suite: update Sys class to nitunit fix
Alexandre Terrasa [Fri, 3 Feb 2017 06:55:34 +0000 (01:55 -0500)]
lib/test_suite: update Sys class to nitunit fix

We need the private method so we can compile the test case with intrude.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotesting: compile before and after methods
Alexandre Terrasa [Fri, 3 Feb 2017 06:54:28 +0000 (01:54 -0500)]
testing: compile before and after methods

Tests case will fail if the before method failed.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotesting: fix `before_module` and `after_module` method recognition
Alexandre Terrasa [Fri, 3 Feb 2017 06:52:33 +0000 (01:52 -0500)]
testing: fix `before_module` and `after_module` method recognition

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotesting: extract `fail` method to make a test case fail without running it
Alexandre Terrasa [Fri, 3 Feb 2017 06:51:55 +0000 (01:51 -0500)]
testing: extract `fail` method to make a test case fail without running it

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: update metrics because the new fictive bottom module
Jean Privat [Wed, 1 Feb 2017 15:29:55 +0000 (10:29 -0500)]
tests: update metrics because the new fictive bottom module

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agomodelbuilder: drop the fictive bottom module if unneeded
Jean Privat [Wed, 1 Feb 2017 13:42:05 +0000 (08:42 -0500)]
modelbuilder: drop the fictive bottom module if unneeded

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agomodelbuilder: add `inject_module_subimportation` to inject importation.
Jean Privat [Tue, 31 Jan 2017 19:35:11 +0000 (14:35 -0500)]
modelbuilder: add `inject_module_subimportation` to inject importation.

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agophase: use a extensible work-list for `run_phases`
Jean Privat [Tue, 31 Jan 2017 19:30:08 +0000 (14:30 -0500)]
phase: use a extensible work-list for `run_phases`

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agoloader: only apply conditional importation on strict submodules
Jean Privat [Tue, 31 Jan 2017 19:25:48 +0000 (14:25 -0500)]
loader: only apply conditional importation on strict submodules

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agomodelbuilder: always create a main fictive module
Jean Privat [Tue, 31 Jan 2017 19:24:58 +0000 (14:24 -0500)]
modelbuilder: always create a main fictive module

This simplify the logic and the number of assumptions.

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agonitc: first_real_mmodule is now explicitly set.
Jean Privat [Tue, 31 Jan 2017 18:54:26 +0000 (13:54 -0500)]
nitc: first_real_mmodule is now explicitly set.

This solve the issue where `nitc foo.nit -m subfoo.nit` program
is named `subfoo` instead of `foo`.

Signed-off-by: Jean Privat <jean@pryen.org>

7 years agorealtime: don't use custom functions on Sierra
Alexis Laferrière [Thu, 2 Feb 2017 16:23:53 +0000 (11:23 -0500)]
realtime: don't use custom functions on Sierra

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agoMerge: nitweb: close quicksearch box when clicking outside of it
Jean Privat [Wed, 18 Jan 2017 20:23:56 +0000 (15:23 -0500)]
Merge: nitweb: close quicksearch box when clicking outside of it

* Add some crappyjs(TM) to autoclose the search box when the user click somewhere else.
* Also autoclose the box when the user click on a link from the list (unwanted js sideeffects are sometimes wanted)

Checks one more box from #2178

Demo: http://nitweb.moz-code.org

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2354

7 years agoMerge: nitweb: auto link entitites found in `span code`
Jean Privat [Wed, 18 Jan 2017 20:23:54 +0000 (15:23 -0500)]
Merge: nitweb: auto link entitites found in `span code`

This PR introduces a stub feature for nitweb: autolinking entities from `span` code.

Each time nitweb renders a Markdown comment it evaluates the content of each inline `code` tag and tries to match it with the model index. If the content of the `code` tag matches a package, module, class or property, the `code` content is wrapped in a link to that entity.

Examples:

* `Object`: will be rendered as `<a href='/doc/core::Object'>Object</a>`
* `nullable Object`: will be rendered as `<a href='/doc/core::Object'>nullable Object</a>`
* `is_same_instance`: will be rendered as `<a href='/doc/core::Object::is_same_instance'>is_same_instance</a>`.

The name matching algorithm is the same as the one used to resolve short links like `[Object]` or complex directives like `[graph: core]`.

Demo: http://nitweb.moz-code.org

The documentation from the `core` package benefits from the new feature: http://nitweb.moz-code.org/doc/core

Pull-Request: #2353

7 years agoMerge: Revamp the C string to Nit string services to put forward the safest alternative
Jean Privat [Wed, 18 Jan 2017 13:42:19 +0000 (08:42 -0500)]
Merge: Revamp the C string to Nit string services to put forward the safest alternative

There are now three services to convert a `CString` to a `String`:

* `CString::to_s` and `to_s_with_length(byte_length)` copies data into the GC memory and clean the UTF-8 characters. The difference is that `to_s` search for the first null byte to find the length of the string. These services are the safest and recommended for use with the FFI. They replace the old `to_s_with_copy` and `to_s_with_copy_and_length`.

* `CString::to_s_unsafe(byte_length, char_length, copy, clean)` is the unsafe alternative. It can optimize conversion of a string that has already been cleaned, is already in the GC memory or of which the number of characters has already been counted. This service unifies (and replace) the old `to_s`, `to_s_with_length`, `to_s_full` and `to_s_unsafe`.

Also fix `from_percent_encoding` that did not clean its output, same for the binary deserialization of single characters, and `environ` which now copies the C string into GC memory.

Update a test result as there is now one more string (the copy by `environ`) and a call to `String::length` to cut on the calls to `CString::utf8_length`.

This PR applies #2057 and it is based on #2347. That a look at the commit "core: revamp `CString::to_s` services" first.

Edit: The full doc and signature of `to_s_unsafe` for ease of reading:

# Get a `String` from the data at `self` (with unsafe options)
#
# The default behavior is the safest and equivalent to `to_s`.
#
# Options:
#
# * Set `byte_length` to the number of bytes to use as data.
#   Otherwise, this method searches for a terminating null byte.
#
# * Set `char_length` to the number of Unicode character in the string.
#   Otherwise, the data is read to count the characters.
#   Ignored if `clean == true`.
#
# * If `copy == true`, the default, copies the data at `self` in the
#   Nit GC allocated memory. Otherwise, the return may still point to
#   the data at `self`.
#
# * If `clean == true`, the default, the string is cleaned of invalid UTF-8
#   characters. If cleaning is necessary, the data is copied into Nit GC
#   managed memory, whether or not `copy == true`.
#   Don't clean only when the data has already been verified as valid UTF-8,
#   other library services rely on UTF-8 compliant characters.
fun to_s_unsafe(byte_length, char_length: nullable Int, copy, clean: nullable Bool): String

Pull-Request: #2350
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

7 years agonitweb: link entities from Markdown code span
Alexandre Terrasa [Sun, 11 Dec 2016 10:27:42 +0000 (05:27 -0500)]
nitweb: link entities from Markdown code span

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: factorize md utilies to MDEmiter instead of DocCommand
Alexandre Terrasa [Sun, 11 Dec 2016 09:28:28 +0000 (04:28 -0500)]
nitweb: factorize md utilies to MDEmiter instead of DocCommand

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: close quick search box when clicking outside
Alexandre Terrasa [Tue, 17 Jan 2017 20:53:46 +0000 (15:53 -0500)]
nitweb: close quick search box when clicking outside

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agoMerge: Benitlux: Improve the iOS variation and general bug fixes
Jean Privat [Tue, 17 Jan 2017 20:44:00 +0000 (15:44 -0500)]
Merge: Benitlux: Improve the iOS variation and general bug fixes

General improvements to Benitlux:
* Don't suggest to follow current friends.
* Don't allow to post a review when not logged in.
* Forget current login on an invalid token and don't recheck them.
* Extract the manual button for checking in and out to its own module.
* Use more precise classes to offer more variation points for platform adaptations.

Improvements to the look on iOS:
* Rely on the new default behavior of the iOS implementation of *app.nit* to ellipsize long texts.
* Less auto correct and auto capitalizing.
* Use placeholder text to identify text fields.
* Prettier views and windows in general, more alignment, text color, sizes, etc.
* Fix icon when the font is missing.

See the result for yourself!
![Benitlux on iOS](http://xymus.net/pub/ben-ios.png)

Pull-Request: #2352

7 years agobenitlux: move manual checkin feature to its own module
Alexis Laferrière [Mon, 2 Jan 2017 19:28:08 +0000 (14:28 -0500)]
benitlux: move manual checkin feature to its own module

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: prettier iOS adaptation
Alexis Laferrière [Mon, 26 Sep 2016 17:29:44 +0000 (13:29 -0400)]
benitlux: prettier iOS adaptation

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: revamp the signup window with more variation points
Alexis Laferrière [Mon, 26 Sep 2016 22:42:06 +0000 (18:42 -0400)]
benitlux: revamp the signup window with more variation points

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: classify views in simple classes as variation points
Alexis Laferrière [Sun, 25 Sep 2016 23:11:07 +0000 (19:11 -0400)]
benitlux: classify views in simple classes as variation points

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux server: don't suggest current friends
Alexis Laferrière [Sun, 25 Sep 2016 23:14:24 +0000 (19:14 -0400)]
benitlux server: don't suggest current friends

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: make BeerView labels public attributes so they are variation points
Alexis Laferrière [Sun, 25 Sep 2016 23:13:53 +0000 (19:13 -0400)]
benitlux: make BeerView labels public attributes so they are variation points

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: refresh home window on receiving an invalid token error
Alexis Laferrière [Sun, 25 Sep 2016 23:12:33 +0000 (19:12 -0400)]
benitlux: refresh home window on receiving an invalid token error

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: don't endlessly recheck token if its invalid
Alexis Laferrière [Sun, 25 Sep 2016 23:10:18 +0000 (19:10 -0400)]
benitlux: don't endlessly recheck token if its invalid

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: fix size and alignment of Star & Follow Button
Alexis Laferrière [Sun, 25 Sep 2016 23:09:07 +0000 (19:09 -0400)]
benitlux: fix size and alignment of Star & Follow Button

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: flatten icon text to path
Alexis Laferrière [Sat, 24 Sep 2016 12:23:24 +0000 (08:23 -0400)]
benitlux: flatten icon text to path

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: expect that native objects will be freed between log ins and outs
Alexis Laferrière [Fri, 23 Sep 2016 14:59:46 +0000 (10:59 -0400)]
benitlux: expect that native objects will be freed between log ins and outs

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: disable autocorrect and autocapital.. on user name input text field
Alexis Laferrière [Fri, 23 Sep 2016 02:59:06 +0000 (22:59 -0400)]
benitlux: disable autocorrect and autocapital.. on user name input text field

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: disable star buttons when not logged in
Alexis Laferrière [Fri, 23 Sep 2016 02:58:36 +0000 (22:58 -0400)]
benitlux: disable star buttons when not logged in

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agobenitlux: drop the custom ellipsizing
Alexis Laferrière [Fri, 23 Sep 2016 02:27:14 +0000 (22:27 -0400)]
benitlux: drop the custom ellipsizing

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agoMerge: calculator: bug fix and small tweaks to the iOS adaptation
Jean Privat [Fri, 30 Dec 2016 20:27:40 +0000 (15:27 -0500)]
Merge: calculator: bug fix and small tweaks to the iOS adaptation

Fix a bug where numbers would be limited to a single digit after some operations.

Improve the look of the calculator under iOS.

Pull-Request: #2351

7 years agoMerge: lib/graph: Fix `to_dot`
Jean Privat [Fri, 30 Dec 2016 20:27:32 +0000 (15:27 -0500)]
Merge: lib/graph: Fix `to_dot`

The `Graph::to_dot` function seldom produced bad dot when used on objects with special formatting in their `to_s` method.

This PR changes that by overriding the ID of a node by an Int.
There is still the concern that the new implementation might explode when used on a very large graph, there might be a better way to generate it or to escape the node's ids, but I can't find another one at the moment.

Poke @ablondin, this might interest you

Pull-Request: #2349
Reviewed-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>

7 years agoMerge: Rename the extern class `NativeString` to `CString`
Jean Privat [Fri, 30 Dec 2016 20:27:19 +0000 (15:27 -0500)]
Merge: Rename the extern class `NativeString` to `CString`

`NativeString` used to be mainly implemented by the engines, but in the last few years it became gradually a normal extern class. As such, its instances are now C strings (`char *`). Most of its methods are extern and implemented in the library instead of the engines. It is also widely used by extern methods implemented in C as `char *`, the type appears 300+ times in the general lib and 67 times in `lib/core/text`.

This PR renames `NativeString` to `CString`. This change makes it clear to beginner programmers that its instances are pointers to C strings and how they are passed to C code. Plus, it fits better next to `CppString`, `JavaString` and `NSString`.

The only remaining engine not using it as a C string is the Java compiler, which implements it as a Java string. This still works and as long as it behaves like a C string there is no problem.

This PR also updates the related doc and attempts to update all indirect references to the new `CString`.

As discussed with @privat and @R4PaSs.

Pull-Request: #2347
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agocalculator: improve iOS variation
Alexis Laferrière [Fri, 9 Sep 2016 12:32:10 +0000 (08:32 -0400)]
calculator: improve iOS variation

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocalculator: update language in variations doc
Alexis Laferrière [Fri, 9 Sep 2016 14:40:42 +0000 (10:40 -0400)]
calculator: update language in variations doc

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocalculator: rename the module `ios_calculator` to `ios`
Alexis Laferrière [Fri, 9 Sep 2016 12:32:49 +0000 (08:32 -0400)]
calculator: rename the module `ios_calculator` to `ios`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocalculator: fix numbers limited to a single digit after a clean
Alexis Laferrière [Wed, 14 Sep 2016 19:59:04 +0000 (15:59 -0400)]
calculator: fix numbers limited to a single digit after a clean

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agotests: update `test_text_stat.res`
Alexis Laferrière [Tue, 27 Dec 2016 03:32:47 +0000 (22:32 -0500)]
tests: update `test_text_stat.res`

There's one more string instance because `environ` output is copied now.
Extra calls to `length` and the like replace calls to `utf8_length`.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years ago*: update all clients of the `CString::to_s` services
Alexis Laferrière [Sat, 24 Dec 2016 16:03:55 +0000 (11:03 -0500)]
*: update all clients of the `CString::to_s` services

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocore: keep `to_s_full` as an indirection for retro compatibility
Alexis Laferrière [Tue, 27 Dec 2016 01:40:40 +0000 (20:40 -0500)]
core: keep `to_s_full` as an indirection for retro compatibility

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocore: revamp `CString::to_s` services
Alexis Laferrière [Sat, 24 Dec 2016 12:57:51 +0000 (07:57 -0500)]
core: revamp `CString::to_s` services

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agolib/graph: Fix `to_dot` that could produce invalid dot when making arcs between inval...
Lucas Bajolet [Mon, 19 Dec 2016 20:45:13 +0000 (15:45 -0500)]
lib/graph: Fix `to_dot` that could produce invalid dot when making arcs between invalid names.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

7 years agoc_src: update with CString
Alexis Laferrière [Tue, 13 Dec 2016 03:54:46 +0000 (22:54 -0500)]
c_src: update with CString

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agoupdate all indirect references to native strings
Alexis Laferrière [Thu, 8 Dec 2016 20:25:41 +0000 (15:25 -0500)]
update all indirect references to native strings

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agotests: update to use `CString`
Alexis Laferrière [Tue, 13 Dec 2016 04:02:45 +0000 (23:02 -0500)]
tests: update to use `CString`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agocore: update doc of `CString`
Alexis Laferrière [Thu, 8 Dec 2016 20:15:49 +0000 (15:15 -0500)]
core: update doc of `CString`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agorename `NativeString` to `CString`
Alexis Laferrière [Thu, 8 Dec 2016 20:12:51 +0000 (15:12 -0500)]
rename `NativeString` to `CString`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

7 years agoMerge: lib/counter: Added pack function
Jean Privat [Thu, 8 Dec 2016 21:58:38 +0000 (16:58 -0500)]
Merge: lib/counter: Added pack function

Added Counter::pack to separate values by occurence into a final 2D array of values

Pull-Request: #2346

7 years agoMerge: lib/for_abuse: Fix typos in documentation
Jean Privat [Thu, 8 Dec 2016 21:58:34 +0000 (16:58 -0500)]
Merge: lib/for_abuse: Fix typos in documentation

Simple fix of a few misuses of `trough` instead of `through`

Pull-Request: #2345
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agoMerge: nitweb: misc fixes
Jean Privat [Thu, 8 Dec 2016 21:58:32 +0000 (16:58 -0500)]
Merge: nitweb: misc fixes

Some cleaning and fixes for nitweb:

* Clean api_auth and login module
* Clean html (extract directives, add menu icons, clean markup)
* Uniformize card headers

Pull-Request: #2344

7 years agoMerge: tests: use NIT_TESTING_ID in neo4j tests
Jean Privat [Thu, 8 Dec 2016 21:58:29 +0000 (16:58 -0500)]
Merge: tests: use NIT_TESTING_ID in neo4j tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2343
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agoMerge: nitweb: add READMEs summaries
Jean Privat [Thu, 8 Dec 2016 21:58:25 +0000 (16:58 -0500)]
Merge: nitweb: add READMEs summaries

Automatically add a summary extracted from the README / doc contents

![image](https://cloud.githubusercontent.com/assets/583144/20892633/fef2fd4a-badc-11e6-89f5-5de007981914.png)

Also add anchors to the content of the README, so you can make links like:

http://nitweb.moz-code.org/doc/core#Methods-Implicitly-Defined-in-Sys

Pull-Request: #2342

7 years agoMerge: lib/text: do not replace undecoded `%` by `?`
Jean Privat [Thu, 8 Dec 2016 21:58:18 +0000 (16:58 -0500)]
Merge: lib/text: do not replace undecoded `%` by `?`

Change the specification of `from_percent_encoding` so undecoded `%` are not replaced by `?`.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2337

7 years agolib/counter: Added pack function
Lucas Bajolet [Wed, 7 Dec 2016 00:07:16 +0000 (19:07 -0500)]
lib/counter: Added pack function

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

7 years agolib/for_abuse: Fix typos in documentation
Lucas Bajolet [Wed, 7 Dec 2016 00:00:07 +0000 (19:00 -0500)]
lib/for_abuse: Fix typos in documentation

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

7 years agonitweb: fix card headers
Alexandre Terrasa [Tue, 6 Dec 2016 19:56:01 +0000 (14:56 -0500)]
nitweb: fix card headers

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: clean scripts import
Alexandre Terrasa [Tue, 6 Dec 2016 19:54:43 +0000 (14:54 -0500)]
nitweb: clean scripts import

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: add some icons in menus
Alexandre Terrasa [Mon, 28 Nov 2016 22:50:14 +0000 (17:50 -0500)]
nitweb: add some icons in menus

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: extract user sidebar directive
Alexandre Terrasa [Wed, 31 Aug 2016 14:42:23 +0000 (10:42 -0400)]
nitweb: extract user sidebar directive

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: move github login configuration to its own module
Alexandre Terrasa [Wed, 31 Aug 2016 14:32:28 +0000 (10:32 -0400)]
nitweb: move github login configuration to its own module

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/core: more tests for percent_encoding
Alexandre Terrasa [Mon, 5 Dec 2016 15:47:22 +0000 (10:47 -0500)]
lib/core: more tests for percent_encoding

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/text: do not replace undecoded `%` by `?`
Alexandre Terrasa [Mon, 28 Nov 2016 22:24:54 +0000 (17:24 -0500)]
lib/text: do not replace undecoded `%` by `?`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: update test for nitcatalog
Alexandre Terrasa [Tue, 6 Dec 2016 18:36:33 +0000 (13:36 -0500)]
tests: update test for nitcatalog

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: test_neo use NIT_TESTING_ID
Alexandre Terrasa [Tue, 6 Dec 2016 18:33:27 +0000 (13:33 -0500)]
tests: test_neo use NIT_TESTING_ID

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: use NIT_TESTING_ID for postgresql tests
Alexandre Terrasa [Tue, 6 Dec 2016 18:23:45 +0000 (13:23 -0500)]
tests: use NIT_TESTING_ID for postgresql tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/postgres: use NIT_TESTING_ID in table names
Alexandre Terrasa [Tue, 6 Dec 2016 18:23:23 +0000 (13:23 -0500)]
lib/postgres: use NIT_TESTING_ID in table names

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/postgres: remove documentation warnings
Alexandre Terrasa [Tue, 6 Dec 2016 18:22:50 +0000 (13:22 -0500)]
lib/postgres: remove documentation warnings

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib/mongo: use NIT_TESTING_ID
Alexandre Terrasa [Tue, 6 Dec 2016 17:49:36 +0000 (12:49 -0500)]
lib/mongo: use NIT_TESTING_ID

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agoMerge: nitweb: rewritte stars
Jean Privat [Mon, 5 Dec 2016 20:53:37 +0000 (15:53 -0500)]
Merge: nitweb: rewritte stars

Upgrade the feedback stars form.

More stars and more details:

![image](https://cloud.githubusercontent.com/assets/583144/20892546/b0155e34-badc-11e6-8f89-726959021e5f.png)

Demo here: http://nitweb.moz-code.org/

Pull-Request: #2341

7 years agoMerge: nitweb: misc fixes
Jean Privat [Mon, 5 Dec 2016 20:53:36 +0000 (15:53 -0500)]
Merge: nitweb: misc fixes

Should fix more points from #2177

* Sort list by alphabetical order
* Remove useless links on doc location
* Remove useless code tabs when the code linearization tab exists

Demo here: http://nitweb.moz-code.org/

Pull-Request: #2340

7 years agoMerge: proposal: lib/config
Jean Privat [Mon, 5 Dec 2016 20:53:32 +0000 (15:53 -0500)]
Merge: proposal: lib/config

We often need basic option handling in our app.

Here a minimalist proposal that covers the basics:
* options holder
* default values
* loading options from ini file

Extract from doc:

# Configuration options for nit tools and apps

This module provides basic services for options handling in your nit programs.

## Basic configuration holder

The `Config` class can be used as a simple option holder and processor:

~~~nit
import config

# Create a new config option
var opt_my = new OptionString("My option", "--my")

# Create the config and add the option
var config = new Config
config.add_option(opt_my)

# Parse the program arguments, usually `args`
config.parse_options(["--my", "myOption", "arg1", "arg2"])

# Access the options and args
assert opt_my.value == "myOption"
assert config.args == ["arg1", "arg2"]
~~~

## Custom configuration class

Instead of using basic `Config` instances, it is better to define new sublcasses
to store options and define custom services.

~~~nit
import config

class MyConfig
super Config

var opt_my = new OptionString("My option", "--my")

init do
super
tool_description = "Usage: MyExample [OPTION]... [ARGS]..."
add_option(opt_my)
end

fun my: String do return opt_my.value or else "Default value"
end

var config = new MyConfig
config.parse_options(["--my", "myOption", "arg1", "arg2"])

assert config.my == "myOption"
assert config.args == ["arg1", "arg2"]
~~~

We define the `my` method to provide an elegant shortcut to `opt_my.value`
and define the default value if the option was not set by the user.

The `tool_description` attribute is used to set the `usage` header printed when
the user request the `help` message.

~~~nit
config.parse_options(["-h"])
if config.help then
config.usage
exit 0
end
~~~

This will display the tool usage like this:

~~~raw
Usage: MyExample [OPTION]... [ARGS]...
 -h, --help   Show this help message
 --my         My option
~~~

## Configuration with `ini` file

The `IniConfig` class provides an easy way to link your configuration to an ini
file.

~~~nit
class MyIniConfig
super IniConfig

var opt_my = new OptionString("My option", "--my")

init do
super
tool_description = "Usage: MyExample [OPTION]... [ARGS]..."
opts.add_option(opt_my)
end

fun my: String do return opt_my.value or else ini["my"] or else "Default"
end
~~~

This time, we define the `my` method to return the option value or the ini
if no option was passed. Finally, if no ini value can be found, we return the
default value.

By default, `IniConfig` looks at a `config.ini` file in the execution directory.
This can be overrided in multiple ways.

First by the app user by setting the `--config` option:

~~~nit
var config = new MyIniConfig
config.parse_options(["--config", "my_config.ini"])

assert config.config_file == "my_config.ini"
~~~

Default config file can also be changed by the library client through the
`default_config_file` attribute:

~~~nit
config = new MyIniConfig
config.default_config_file = "my_config.ini"
config.parse_options(["arg"])

assert config.config_file == "my_config.ini"
~~~

Or by the library developper in the custom config class:

~~~nit
class MyCustomIniConfig
super IniConfig

redef var default_config_file = "my_config.ini"
end

var config = new MyCustomIniConfig
config.parse_options(["arg"])

assert config.config_file == "my_config.ini"
~~~

Pull-Request: #2339
Reviewed-by: Jean Privat <jean@pryen.org>

7 years agoMerge: nitweb: encode URIs
Jean Privat [Mon, 5 Dec 2016 20:53:28 +0000 (15:53 -0500)]
Merge: nitweb: encode URIs

Closes #2164

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2338
Reviewed-by: Jean-Christophe Beaupré <jcbrinfo.public@gmail.com>

7 years agocatalog: fix double H1 display from package page
Alexandre Terrasa [Mon, 5 Dec 2016 18:36:51 +0000 (13:36 -0500)]
catalog: fix double H1 display from package page

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: fix model_json output with alphabetical order
Alexandre Terrasa [Mon, 5 Dec 2016 18:23:09 +0000 (13:23 -0500)]
tests: fix model_json output with alphabetical order

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: use NIT_TESTING_ID in neo4j tests
Alexandre Terrasa [Mon, 5 Dec 2016 18:01:46 +0000 (13:01 -0500)]
tests: use NIT_TESTING_ID in neo4j tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agotests: fix nitrpg tests
Alexandre Terrasa [Mon, 5 Dec 2016 15:42:05 +0000 (10:42 -0500)]
tests: fix nitrpg tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: migrate to config
Alexandre Terrasa [Sat, 3 Dec 2016 04:15:51 +0000 (23:15 -0500)]
nitweb: migrate to config

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agopopcorn: pop_repos use config
Alexandre Terrasa [Sat, 3 Dec 2016 04:15:30 +0000 (23:15 -0500)]
popcorn: pop_repos use config

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agopopcorn: pop_config use config
Alexandre Terrasa [Sat, 3 Dec 2016 04:14:58 +0000 (23:14 -0500)]
popcorn: pop_config use config

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agolib: introduce basic config classes
Alexandre Terrasa [Sat, 3 Dec 2016 03:45:03 +0000 (22:45 -0500)]
lib: introduce basic config classes

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: add sumaries to doc pages
Alexandre Terrasa [Sat, 3 Dec 2016 02:10:38 +0000 (21:10 -0500)]
nitweb: add sumaries to doc pages

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agodoc_down: render synopsis as `h1`
Alexandre Terrasa [Sat, 3 Dec 2016 02:10:25 +0000 (21:10 -0500)]
doc_down: render synopsis as `h1`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: remove useless links on locations
Alexandre Terrasa [Thu, 25 Aug 2016 20:36:52 +0000 (16:36 -0400)]
nitweb: remove useless links on locations

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: remove useless code tabs for propdefs and classdefs
Alexandre Terrasa [Thu, 25 Aug 2016 20:34:28 +0000 (16:34 -0400)]
nitweb: remove useless code tabs for propdefs and classdefs

Since the code is already loaded in the linearization list

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: sort mentities list by name
Alexandre Terrasa [Thu, 25 Aug 2016 20:33:11 +0000 (16:33 -0400)]
nitweb: sort mentities list by name

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: clean defs list rendering
Alexandre Terrasa [Thu, 25 Aug 2016 20:20:04 +0000 (16:20 -0400)]
nitweb: clean defs list rendering

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: show grade overview in specific page
Alexandre Terrasa [Mon, 28 Nov 2016 21:49:28 +0000 (16:49 -0500)]
nitweb: show grade overview in specific page

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: show grades in user page
Alexandre Terrasa [Thu, 4 Aug 2016 18:48:52 +0000 (14:48 -0400)]
nitweb: show grades in user page

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

7 years agonitweb: rewrite stars display
Alexandre Terrasa [Thu, 4 Aug 2016 18:48:03 +0000 (14:48 -0400)]
nitweb: rewrite stars display

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>