Skip to content

Refactor to linkifyjs! #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

marksyzm
Copy link

@marksyzm marksyzm commented Feb 8, 2016

Remove old modules.
Create build process for publishing.
Add new linkify integration with angular.

@marksyzm
Copy link
Author

marksyzm commented Feb 8, 2016

Oh, just noticed the readme needs updating. Will get onto that... should probably do that before any publishing!

var options = angular.extend(defaultOptions, scope.options);

scope.$evalAsync(function () {
try {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a try/catch here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bizarre error on their part where if it finds just one text node that's empty, it errors and breaks the module

@scottcorgan
Copy link
Owner

@marksyzm so far, this is looking good!

My number 1 concern in this PR is the the change it makes to the size of the bundle. It seems to almost quadruple it. I'm actually ok with that if it solves a more general problem.

Also, when you get the tests in, make sure they run against the old code as well as the new code (at least the functionality of the old code). That way we can be confident that there aren't regressions.

Thanks again!

@marksyzm
Copy link
Author

marksyzm commented Feb 9, 2016

Well, the requirement of linkifyjs is basically the issue, there, size-wise, because it's bundled into the build script. I don't think there's a way around that when it's being put into real use, even if I manage to get the build to remove linkifyjs scripts and just bundle up the modules, but at least you get the new configurable set up (worth a look at: http://soapbox.github.io/linkifyjs/docs/options.html). If someone were to use this via bower, they would use the built plugin, else NPM via webpack or similar means they can separately install versions of linkifyjs in their node_modules. It takes responsibility for the link parsing away, which will help.

What's also nice there is that you can chuck in plugins of your own too by using their plugin system.

@marksyzm
Copy link
Author

marksyzm commented Feb 9, 2016

As for the tests, do you mean create a separate tag for the old stuff and create tests based on those also? The old stuff is no longer there in this build; I was just going to create tests for the new services, directive and filter otherwise.

@marksyzm
Copy link
Author

marksyzm commented Feb 9, 2016

I had to refactor to allow for a new system where it just takes in a string as first argument for each, and an object for second which matches up with the format that linkifyjs uses, so now when applying a filter you would do this:

<!-- filter -->
<div ng-bind-html="{{ 'www.google.com' | linkify: { nl2br: true, defaultProtocol: 'https' } }}"></div>
<!-- directive -->
<div linkify>{{'www.google.com'}}</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants