Browse Source

pkg done

master
boB Rudis 2 years ago
parent
commit
83ce4b4000
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      .Rbuildignore
  2. 12
      DESCRIPTION
  3. 2
      LICENSE
  4. 21
      LICENSE.md
  5. 4
      NAMESPACE
  6. 10
      R/slugify-package.R
  7. 38
      R/slugify.R
  8. 12
      R/zzz.R
  9. 4
      README.Rmd
  10. 71
      README.md
  11. 4
      inst/js/bld
  12. 74
      inst/js/bundle.js
  13. 1
      inst/js/in.js
  14. 21
      inst/js/node_modules/slugify/LICENSE
  15. 81
      inst/js/node_modules/slugify/README.md
  16. 73
      inst/js/node_modules/slugify/package.json
  17. 22
      inst/js/node_modules/slugify/slugify.d.ts
  18. 66
      inst/js/node_modules/slugify/slugify.js
  19. 11
      inst/js/package-lock.json
  20. 5
      inst/tinytest/test_slugify.R
  21. 24
      man/slugify.Rd

4
.Rbuildignore

@ -19,3 +19,7 @@
^CRAN-RELEASE$
^appveyor\.yml$
^tools$
^LICENSE\.md$
^bld$
^node_modules^
^package-lock\\.json$

12
DESCRIPTION

@ -1,6 +1,6 @@
Package: slugify
Type: Package
Title: slugify title goes here otherwise CRAN checks fail
Title: Create slug strings for SEO
Version: 0.1.0
Date: 2020-06-26
Authors@R: c(
@ -8,17 +8,17 @@ Authors@R: c(
comment = c(ORCID = "0000-0001-5670-2640"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A good description goes here otherwise CRAN checks fail.
Description: Most blogging platforms turn title phrases into slugs
for better SEO. Tools are provided to turn phrases into slugs.
URL: https://git.rud.is/hrbrmstr/slugify
BugReports: https://git.rud.is/hrbrmstr/slugify/issues
Encoding: UTF-8
License: AGPL
License: MIT + file LICENSE
Suggests:
covr, tinytest
Depends:
R (>= 3.5.0)
R (>= 3.6.0)
Imports:
httr,
jsonlite
V8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2020
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2020 Bob Rudis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4
NAMESPACE

@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
import(httr)
importFrom(jsonlite,fromJSON)
export(slugify)
import(V8)

10
R/slugify-package.R

@ -1,9 +1,11 @@
#' ...
#'
#' Create slug strings for SEO
#'
#' Most blogging platforms turn title phrases into slugs
#' for better SEO. Tools are provided to turn phrases into slugs.
#'
#' @md
#' @name slugify
#' @keywords internal
#' @author Bob Rudis (bob@@rud.is)
#' @import httr
#' @importFrom jsonlite fromJSON
#' @import V8
"_PACKAGE"

38
R/slugify.R

@ -0,0 +1,38 @@
#' Slugif a string
#'
#' @param x string
#' @param replacement replace spaces with replacement character, defaults to `-`
#' @param remove remove characters that match this regex, defaults to `NULL` (no deleting)
#' @param lower convert to lower case, defaults to `TRUE`
#' @param strict strip special characters except replacement, defaults to `TRUE`
#' @export
#' @examples
#' slugify("R is great!")
slugify <- function(x, replacement = "-", remove = NULL, lower = TRUE, strict = TRUE) {
if (!is.null(remove)) {
.pkgenv$ctx$call(
"slugify", x[1],
list(
replacement = "-",
remove = remove[1],
lower = lower[1],
strict = strict[1]
)
)
} else {
.pkgenv$ctx$call(
"slugify", x[1],
list(
replacement = "-",
lower = lower[1],
strict = strict[1]
)
)
}
}

12
R/zzz.R

@ -0,0 +1,12 @@
.pkgenv <- new.env(parent=emptyenv())
.onLoad <- function(...) {
ctx <- V8::v8()
ctx$source(system.file("js/bundle.js", package="slugify"))
assign("ctx", ctx, envir=.pkgenv)
cache <- list()
}

4
README.Rmd

@ -39,6 +39,10 @@ packageVersion("slugify")
```
```{r ex-01}
slugify("R is great!")
```
## slugify Metrics
```{r cloc, echo=FALSE}

71
README.md

@ -0,0 +1,71 @@
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/slugify.svg?branch=master)](https://travis-ci.org/hrbrmstr/slugify)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# slugify
Create slug strings for SEO
## Description
Most blogging platforms turn title phrases into slugs for better SEO.
Tools are provided to turn phrases into slugs.
## What’s Inside The Tin
The following functions are implemented:
## Installation
``` r
remotes::install_git("https://git.rud.is/hrbrmstr/slugify.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/slugify")
# or
remotes::install_gitlab("hrbrmstr/slugify")
# or
remotes::install_bitbucket("hrbrmstr/slugify")
# or
remotes::install_github("hrbrmstr/slugify")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
``` r
library(slugify)
# current version
packageVersion("slugify")
## [1] '0.1.0'
```
``` r
slugify("R is great!")
## [1] "r-is-great"
```
## slugify Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | --: | --: | ---: | ----------: | ---: | -------: | --: |
| R | 4 | 0.8 | 33 | 0.79 | 13 | 0.45 | 20 | 0.4 |
| Rmd | 1 | 0.2 | 9 | 0.21 | 16 | 0.55 | 30 | 0.6 |
## Code of Conduct
Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

4
inst/js/bld

@ -0,0 +1,4 @@
npm install slugify
echo "global.slugify = require('slugify');" > in.js
browserify in.js -o bundle.js
#webpack --mode="production" in.js -o bundle.js

74
inst/js/bundle.js

File diff suppressed because one or more lines are too long

1
inst/js/in.js

@ -0,0 +1 @@
global.slugify = require('slugify');

21
inst/js/node_modules/slugify/LICENSE

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Simeon Velichkov <simeonvelichkov@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

81
inst/js/node_modules/slugify/README.md

@ -0,0 +1,81 @@
# slugify
[![npm-version]][npm] [![travis-ci]][travis] [![coveralls-status]][coveralls]
```js
var slugify = require('slugify')
slugify('some string') // some-string
// if you prefer something other than '-' as separator
slugify('some string', '_') // some_string
```
- Vanilla ES5 JavaScript
- No dependencies
- Coerces foreign symbols to their English equivalent (check out the [charMap][charmap] for more details)
- Works in the browser (window.slugify) and AMD/CommonJS-flavored module loaders
## Options
```js
slugify('some string', {
replacement: '-', // replace spaces with replacement character, defaults to `-`
remove: undefined, // remove characters that match regex, defaults to `undefined`
lower: false, // convert to lower case, defaults to `false`
strict: false, // strip special characters except replacement, defaults to `false`
})
```
For example, to remove `*+~.()'"!:@` from the result slug, you can use `slugify('..', {remove: /[*+~.()'"!:@]/g})`.
## Extend
Out of the box `slugify` comes with support for a handful of Unicode symbols. For example the `☢` (radioactive) symbol is not defined in the [`charMap`][charmap] and therefore it will be stripped by default:
```js
slugify('unicode ♥ is ☢') // unicode-love-is
```
However you can extend the supported symbols, or override the existing ones with your own:
```js
slugify.extend({'☢': 'radioactive'})
slugify('unicode ♥ is ☢') // unicode-love-is-radioactive
```
Keep in mind that the `extend` method extends/overrides the default `charMap` for the entire process. In case you need a fresh instance of the slugify's `charMap` object you have to clean up the module cache first:
```js
delete require.cache[require.resolve('slugify')]
var slugify = require('slugify')
```
## Contribute
1. Add chars to `charmap.json`
2. Run tests `npm test`
3. The tests will build the charmap in `index.js` and will sort the `charmap.json`
4. Commit **all** modified files
---
> This module was originally a vanilla javascript port of [node-slug][node-slug].<br>
> Note that the original [slug][slug] module has been ported to vanilla javascript too.<br>
> One major difference between the two modules is that `slugify` does not depend on the external [unicode][unicode] module.
[npm-version]: https://img.shields.io/npm/v/slugify.svg?style=flat-square (NPM Package Version)
[travis-ci]: https://img.shields.io/travis/simov/slugify/master.svg?style=flat-square (Build Status - Travis CI)
[coveralls-status]: https://img.shields.io/coveralls/simov/slugify.svg?style=flat-square (Test Coverage - Coveralls)
[npm]: https://www.npmjs.com/package/slugify
[travis]: https://travis-ci.org/simov/slugify
[coveralls]: https://coveralls.io/r/simov/slugify?branch=master
[node-slug]: https://github.com/dodo/node-slug
[slug]: https://www.npmjs.com/package/slug
[unicode]: https://www.npmjs.com/package/unicode
[index]: https://github.com/simov/slugify/blob/master/index.js
[charmap]: https://github.com/simov/slugify/blob/master/config/charmap.json

73
inst/js/node_modules/slugify/package.json

@ -0,0 +1,73 @@
{
"_from": "slugify",
"_id": "slugify@1.4.2",
"_inBundle": false,
"_integrity": "sha512-7UfMG5rtkxfOI5jg/+f4DMQS3ikUqfWnfMvitrhwdTV4pibWXq9mN4RNLHSV3M1lR++x7z+AG7znsiozdBP+aA==",
"_location": "/slugify",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "slugify",
"name": "slugify",
"escapedName": "slugify",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/slugify/-/slugify-1.4.2.tgz",
"_shasum": "2c9b2b3321c43110a0058982eea7102b998d5068",
"_spec": "slugify",
"_where": "/Users/hrbrmstr/packages/slugify/inst/js",
"author": {
"name": "Simeon Velichkov",
"email": "simeonvelichkov@gmail.com",
"url": "https://simov.github.io"
},
"bugs": {
"url": "https://github.com/simov/slugify/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Slugifies a String",
"devDependencies": {
"coveralls": "^3.1.0",
"mocha": "^7.2.0",
"nyc": "^15.1.0"
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"LICENSE",
"README.md",
"slugify.d.ts",
"slugify.js"
],
"homepage": "https://github.com/simov/slugify",
"keywords": [
"slugify",
"slug",
"url",
"urlify"
],
"license": "MIT",
"main": "./slugify.js",
"name": "slugify",
"repository": {
"type": "git",
"url": "git+https://github.com/simov/slugify.git"
},
"scripts": {
"build": "node bin/build",
"test": "npm run build && npm run test:ci",
"test:ci": "npx mocha --recursive",
"test:cov": "npx nyc --reporter=lcov --reporter=text-summary mocha -- --recursive"
},
"types": "slugify.d.ts",
"version": "1.4.2"
}

22
inst/js/node_modules/slugify/slugify.d.ts

@ -0,0 +1,22 @@
declare module slugify {
type ExtendArgs = {
[key: string]: any;
}
export function extend (args: ExtendArgs): void;
}
declare function slugify(
string: string,
options?:
| {
replacement?: string;
remove?: RegExp;
lower?: boolean;
strict?: boolean;
}
| string,
): string;
export default slugify;

66
inst/js/node_modules/slugify/slugify.js

File diff suppressed because one or more lines are too long

11
inst/js/package-lock.json

@ -0,0 +1,11 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"slugify": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.4.2.tgz",
"integrity": "sha512-7UfMG5rtkxfOI5jg/+f4DMQS3ikUqfWnfMvitrhwdTV4pibWXq9mN4RNLHSV3M1lR++x7z+AG7znsiozdBP+aA=="
}
}
}

5
inst/tinytest/test_slugify.R

@ -1,4 +1,3 @@
library(slugify)
# Placeholder with simple test
expect_equal(1 + 1, 2)
expect_true(slugify("R is great!") == "r-is-great")

24
man/slugify.Rd

@ -1,12 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/slugify-package.R
% Please edit documentation in R/slugify-package.R, R/slugify.R
\docType{package}
\name{slugify}
\alias{slugify}
\alias{slugify-package}
\title{...}
\title{Create slug strings for SEO}
\usage{
slugify(x, replacement = "-", remove = NULL, lower = TRUE, strict = TRUE)
}
\arguments{
\item{x}{string}
\item{replacement}{replace spaces with replacement character, defaults to \code{-}}
\item{remove}{remove characters that match this regex, defaults to \code{NULL} (no deleting)}
\item{lower}{convert to lower case, defaults to \code{TRUE}}
\item{strict}{strip special characters except replacement, defaults to \code{TRUE}}
}
\description{
A good description goes here otherwise CRAN checks fail.
Most blogging platforms turn title phrases into slugs
for better SEO. Tools are provided to turn phrases into slugs.
}
\examples{
slugify("R is great!")
}
\seealso{
Useful links:

Loading…
Cancel
Save